Re: [R] Wayland backend for R

2021-06-23 Thread Phillips Rogfield
Dear Robert,

Thank you very much for your suggestion.

I solved by compiling R with --with-cairo, and installing cairo-devel 
and pango-devel.

Notably, you also need pango-devel.

The configure script does not complain if it is missing, but then 
plotting won't work.

Best regards.

On 23/06/2021 20:26, Robert Knight wrote:
> Perhaps software rendering would work.
>
> |Export RSTUDIO_CHROMIUM_ARGUMENTS="--disable-gpu"|
> |/usr/lib/rstudio/bin/rstudio|
>
> On Wed, Jun 23, 2021, 10:01 AM Phillips Rogfield 
> mailto:thebudge...@gmail.com>> wrote:
>
> Hello Paul,
>
> thank you for your kind advice.
>
> RStudio doesn't start at all this way. It gives me the following
> error:
>
> $ QT_QPA_PLATFORM=wayland rstudio
> Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use
> QT_QPA_PLATFORM=wayland to run on Wayland anyway.
> QSocketNotifier: Can only be used with threads started with QThread
> Failed to load client buffer integration: wayland-egl
>
> WebEngineContext used before QtWebEngine::initialize() or OpenGL
> context
> creation failed.
> qt.qpa.wayland: No shell integration named "xdg-shell" found
> qt.qpa.wayland: No shell integration named "xdg-shell-v6" found
> qt.qpa.wayland: No shell integration named "wl-shell" found
> qt.qpa.wayland: No shell integration named "ivi-shell" found
> qt.qpa.wayland: Loading shell integration failed.
> qt.qpa.wayland: Attempted to load the following shells ("xdg-shell",
> "xdg-shell-v6", "wl-shell", "ivi-shell")
> qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
>
> Best regards.
>
> On 23/06/2021 02:22, Paul Murrell wrote:
> > Hi
> >
> > I do not know of any Wayland backend for R.
> >
> > You might be able to try the R Studio IDE configured for Wayland
> and
> > see how its graphics device performs ?
> > https://github.com/rstudio/rstudio/issues/4686
> <https://github.com/rstudio/rstudio/issues/4686>
> >
> > Paul
> >
> > On 23/06/21 1:25 am, Phillips Rogfield wrote:
> >> I have compiled R from source and I had to install the X11
> libraries.
> >>
> >> I use Wayland, and I am having problems plotting on X11 (I
> guess it uses
> >> XWayland) with this version.
> >>
> >> Is there a Wayland backend for R?
> >>
> >> Some configuration option I need to turn on in order to use it?
> >>
> >> __
> >> R-help@r-project.org <mailto:R-help@r-project.org> mailing list
> -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> >> <https://stat.ethz.ch/mailman/listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>>
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> >> <http://www.R-project.org/posting-guide.html
> <http://www.R-project.org/posting-guide.html>>
> >> and provide commented, minimal, self-contained, reproducible code.
> >
>
> __
> R-help@r-project.org <mailto:R-help@r-project.org> mailing list --
> To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Phillips Rogfield
Dear all,

thank for for your suggestion.

Yes I come from languages where 1 means TRUE and 0 means FALSE. In 
particular from C/C++ and Python.

Evidently this is not the case for R.

In my mind I kind took for granted that that was the case (1=TRUE, 0=FALSE).

Knowing this is not the case for R makes things simpler.

Mine was just an example, sometimes I load datasets taken from outside 
and variables are coded with 1/0 (for example, a treatment variable may 
be coded that way).

I also did not know the !!() syntax!

Thank you for your help and best regards.

On 23/06/2021 17:55, Bert Gunter wrote:
> Just as a way to save a bit of typing, instead of
>
> > as.logical(0:4)
> [1] FALSE  TRUE  TRUE  TRUE  TRUE
>
> > !!(0:4)
> [1] FALSE  TRUE  TRUE  TRUE  TRUE
>
> DO NOTE that the parentheses in the second expression should never be 
> omitted, a possible reason to prefer the as.logical() construction.
> Also note that !!  "acts [only] on raw, logical and number-like 
> vectors," whereas as.logical() is more general. e.g. (from ?logical):
>
> > charvec <- c("FALSE", "F", "False", "false",    "fAlse", "0",
> +              "TRUE",  "T", "True",  "true",     "tRue",  "1")
> > as.logical(charvec)
>  [1] FALSE FALSE FALSE FALSE    NA    NA  TRUE  TRUE  TRUE  TRUE    NA 
>    NA
> > !!charvec
> Error in !charvec : invalid argument type
>
>
> Cheers,
> Bert
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along 
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Jun 23, 2021 at 8:31 AM Eric Berger  <mailto:ericjber...@gmail.com>> wrote:
>
> In my code, instead of 't', I name a vector of indices with a
> meaningful
> name, such as idxV, to make it obvious.
>
> Alternatively, a minor change in your style would be to replace your
> definition of t by
>
> t <- as.logical(c(1,1,1,0,0))
>
> HTH,
> Eric
>
>
> On Wed, Jun 23, 2021 at 6:11 PM Phillips Rogfield
> mailto:thebudge...@gmail.com>>
> wrote:
>
> > I make the same mistake all over again.
> >
> > In particular, suppose we have:
> >
> > a = c(1,2,3,4,5)
> >
> > and a variable that equals 1 for the elements I want to select:
> >
> > t = c(1,1,1,0,0)
> >
> > To select the first 3 elements.
> >
> > The problem is that
> >
> > a[t]
> >
> > would repeat the first element 3 times .
> >
> > I have to either convert `t` to boolean:
> >
> > a[t==1]
> >
> > Or use `which`
> >
> > a[which(t==1)]
> >
> > How can I "spot" this error?
> >
> > It often happens in long scripts.
> >
> > Do I have to check the type each time?
> >
> > Do you have any suggestions?
> >
> > __
> > R-help@r-project.org <mailto:R-help@r-project.org> mailing list
> -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>         [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org <mailto:R-help@r-project.org> mailing list --
> To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Plot NUTS regions with color

2021-06-23 Thread Phillips Rogfield
Dear R-help ML,

I have downloaded the NUTS shapefiles from here: 
https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/administrative-units-statistical-units/nuts

I can load them with the following code:

library(rgdal)
shp_bdir <- [PATH TO SHAPE FILE]
layername <- "NUTS_RG_01M_2021_4326"
shp_folder <- file.path(shp_bdir, paste0(layername,".shp"))
EU_NUTS <- readOGR(dsn = shp_folder, layer = layername)

Then I can plot the regions with:

plot(EU_NUTS)

Now I have a list of NUTS - 3 Level, for example:

l <- c("AT223", "AT212", "AT212", "AT121")

I would like a plot where the NUTS regions are colored, and the more a 
particular NUTS is present is the list, the darker its color.

For example "AT212" should be darker than "AT223", because the former is 
present two times in the list.

How can I achieve that?

Thank you and best regards.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to spot/stop making the same mistake

2021-06-23 Thread Phillips Rogfield

I make the same mistake all over again.

In particular, suppose we have:

a = c(1,2,3,4,5)

and a variable that equals 1 for the elements I want to select:

t = c(1,1,1,0,0)

To select the first 3 elements.

The problem is that

a[t]

would repeat the first element 3 times .

I have to either convert `t` to boolean:

a[t==1]

Or use `which`

a[which(t==1)]

How can I "spot" this error?

It often happens in long scripts.

Do I have to check the type each time?

Do you have any suggestions?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Mediation analysis takes up all RAM, then all swap, and then RStudio/terminal suddenly closes

2021-06-23 Thread Phillips Rogfield
Hello Bert,

thank you for your kinds answer.

No I didn't contact the maintainer of the package first, that's my fault :)

I have come to the conclusion that the problem is that I don't have 
enough resources on my PC (RAM) for the task at hand.

I have tried to run it on a remote VM with more RAM and seems to work.

Best regards

On 22/06/2021 17:50, Bert Gunter wrote:
> Please read and follow the posting guide, linked below, which says:
>
> "For questions about functions in standard packages distributed with R 
> (see the FAQ Add-on packages in R 
> ), 
> ask questions on R-help.
> If the question relates to a /contributed package/ , e.g., one 
> downloaded from CRAN, try contacting the package maintainer first. You 
> can also use |find("functionname")| and 
> |packageDescription("packagename")| to find this information. *Only* 
> send such questions to R-help or R-devel if you get no reply or need 
> further assistance. This applies to both requests for help and to bug 
> reports."
>
> So, while you *may* get a useful response here, you should contact the 
> maintainer. If you have already done so, please say so.
>
> Another possibility that may be helpful is the Fedora SIG, 
> https://stat.ethz.ch/mailman/listinfo/r-sig-fedora 
>  , though of 
> course I have no idea whether your problem is OS specific.
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along 
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Tue, Jun 22, 2021 at 8:38 AM Philips Roger  > wrote:
>
> I am using the mediation
>  >
> package to run a mediation analysis.
>
> But when I call the `mediate` function, R eats up all RAM, then it
> eats
> up all swap, and then RStudio suddenly closes.
>
> The same happens if I call `Rscript` from the terminal, and the
> terminal
> suddenly closes.
>
> Here is measures for RAM and swap. Notice the peaks:
>
> RAM diagnostics
>
> I have Fedora Worstation 24.
>
> This happens BOTH with the R 4.0.5 that uses Open BLAS provided in
> the
> Fedora repository, and a custom R 4.1.0 I compiled from source linked
> against Intel MKL.
>
> It doesn't seem to happen every time, some times (rarely), the RAM
> stays
> constant (around 40/50%) and it works (it takes a long time through).
>
> What is the cause of this? How can I debug?
>
> __
> R-help@r-project.org  mailing list --
> To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> 
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> 
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Wayland backend for R

2021-06-23 Thread Phillips Rogfield

Hello Paul,

thank you for your kind advice.

RStudio doesn't start at all this way. It gives me the following error:

$ QT_QPA_PLATFORM=wayland rstudio
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use 
QT_QPA_PLATFORM=wayland to run on Wayland anyway.

QSocketNotifier: Can only be used with threads started with QThread
Failed to load client buffer integration: wayland-egl

WebEngineContext used before QtWebEngine::initialize() or OpenGL context 
creation failed.

qt.qpa.wayland: No shell integration named "xdg-shell" found
qt.qpa.wayland: No shell integration named "xdg-shell-v6" found
qt.qpa.wayland: No shell integration named "wl-shell" found
qt.qpa.wayland: No shell integration named "ivi-shell" found
qt.qpa.wayland: Loading shell integration failed.
qt.qpa.wayland: Attempted to load the following shells ("xdg-shell", 
"xdg-shell-v6", "wl-shell", "ivi-shell")

qt.qpa.wayland: Wayland does not support QWindow::requestActivate()

Best regards.

On 23/06/2021 02:22, Paul Murrell wrote:

Hi

I do not know of any Wayland backend for R.

You might be able to try the R Studio IDE configured for Wayland and 
see how its graphics device performs ?

https://github.com/rstudio/rstudio/issues/4686

Paul

On 23/06/21 1:25 am, Phillips Rogfield wrote:

I have compiled R from source and I had to install the X11 libraries.

I use Wayland, and I am having problems plotting on X11 (I guess it uses
XWayland) with this version.

Is there a Wayland backend for R?

Some configuration option I need to turn on in order to use it?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help 
<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html 
<http://www.R-project.org/posting-guide.html>

and provide commented, minimal, self-contained, reproducible code.




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Wayland backend for R

2021-06-22 Thread Phillips Rogfield

I have compiled R from source and I had to install the X11 libraries.

I use Wayland, and I am having problems plotting on X11 (I guess it uses 
XWayland) with this version.


Is there a Wayland backend for R?

Some configuration option I need to turn on in order to use it?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.