cannot load rgl package without manually launching Xapp - r

I initially tried, using RStudio, to install rgl using install.packages("rgl"), which appeared to have worked. It did give me a message that the binary is older than the source, and that it would install from the binary, but I received no other messages. However library(rgl) gets stuck and doesn't do anything.
I removed the package using remove.packages(rgl), and attempted to install from source using R CMD INSTALL rgl_0.95.1409.tar.gz. That gets stuck on "testing if installed package can be loaded." I had X11 installed, but I downloaded XQuartz 2.7.8 and tried again, with the same result.
?rgl::plot3d in RStudio does take me to the documentation for the plot3d function, so I think it installed, just not completely/successfully (rgl::plot3d as an attempt to call the plot3d function also results in endless computation).
However, I finally did manage to load rgl (and use plot3d) by manually launching the Xapp from the Terminal prior to loading the library in my current R session (just X in Terminal, xterm by itself doesn't seem to have the same effect). Can anyone explain why this might be the case, and if there is a workaround to avoid having to manually launch the Xapp? (I do not want to have an application running when I do not need it, but I will also probably sometimes forget to launch the Xapp prior to running this script.)
I'm running OS X Yosemite (10.10.5), RStudio 0.98.1103, R 3.1.3 3.2.2.

The 'rgl' package does not use XQuartz, but rather opens a separate X11 window. Not being able to launch X(11) automatically makes me think that either your system PATH does not have the X11 server in the search path or an environment variable needs to be fixed. I wasn't able to see any differences in the Sys.getenv() results after loading rgl but I see that I have these in my PATH: /usr/X11/bin:/usr/X11R6/bin1
For a while I was rather confused about this as well. The XQuartz.app appeared very similar to the the X11.app , showing up with the very similar icons, (both appearing in the Taskbar as "X".)

Related

Unable to load fonts on Ubuntu

Using R version 4.1.2 on Ubuntu 20.04, I run hist(10). The error says
X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 2 at size 14 could not be loaded
I find two things on google. This thread I can't understand, and this thread suggests I build R differently. I did recently build R from source, without the cairo flag recommended by the Bio-Deago github thread, but I have now replaced it with a binary from Rstudio, and the problem persists. Any suggestions? Thanks!
EDIT: the problem only occurs in Rstudio, not when I run R through a terminal.
R gets installed to different places depending on whether you install from source or as a binary: see this, which says:
For versions of R installed by system package managers (e.g. r-base on Debian or Ubuntu) this will be /usr/bin/R. For versions of R installed from source this will typically (but not always) be /usr/local/bin/R.
Rstudio looks first at which R, which in this case is the version from source. I deleted the source version (target of symlink at which R). Then when I ran R in a terminal, said R is not installed. Then, I followed the Rstudio binary install instructions mentioned in the question. I followed them from the beginning even though I had already installed an Rstudio binary. Now I can run hist(10) and get a plot as expected.

Which runtime is getting referenced

I have installed R at following location C:\E_Drive\ProgramFiles\R-3.4.3, so I think R environment installed at C:\E_Drive\ProgramFiles\R-3.4.3 will be used when I run the R console, right? Please correct me if I am wrong.
Now, I install a package using the R console.
Now, I download and install RStudio and from the R console of RStudio if I check whether that package is available or not then I see that it is available. I am wondering, how RStudio's R console reported that package is available, I didn't expect that since C:\E_Drive\ProgramFiles\R-3.4.3 is not on my PATH and in no way is linked RStudio with C:\E_Drive\ProgramFiles\R-3.4.3, so I thought RStudio would be referring its own R environment.
Can you please help me understand how my RStudio is referencing the C:\E_Drive\ProgramFiles\R-3.4.3 R environment.
R normally installs packages in the same directory tree as its own binary, but it can also install them elsewhere. On Windows, this generally happens because regular users often don't have write permission in the Program Files directory. The standard Windows installer also records R's location in the registry, so that it doesn't need to be on the PATH to be found by RStudio.
You can find out where Windows or RStudio found R by running R.home() within R. You can find out where R is finding packages in a particular session by running .libPaths().

how to read a SAS data (.sas7bat) in R [duplicate]

I am trying to embed RInside to my application on win7 64-bit system but when I initialize an RInside:
Rin = new RInside(argc, argv);
the following message appears:
Error in loadNamespace(name) : there is no package called 'Rcpp'
This error only occurs with Windows.
I think you get that issue when your .libPaths() differ--in other words run the .libPaths() function to see the paths stored by R for its use. Then check where RInside is installed, and make sure Rcpp is installed there too. It is a setup issue.
In other words, it should work if you have Rcpp and RInside installed where the basic R libraries are. Otherwise you have to tell the (embedded) R session about the other location (and before it starts).
There are more Windows users on the list, so you could try asking on rcpp-devel.
First get your default library locations by command ".Library" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step1.
Now you are ready to install packages which have dependencies on Rcpp.
Dirk is right in this case, BUT if the .libPaths() does not work, then please also check if you have the latest packages.
I am posting this as an ancillary answer backup which I ran into with the shiny package backend switch of their code needing Rcpp!
In this case of getting the "no package" error message, I fixed it by:
Selecting devtools package and then using this line below. (if you don't have devtools then get it with install.packages("devtools")
devtools::install_github("rstudio/shiny")
The development version of the package handled this better, and added the package as a dependency.
Mods - I realize this is an answer to an old question, but I might help others not wasting an hour like I just did.
You might find it easy if the answers are for both R studio users and non R studio users.
R Studio users
First get your default library locations by command ".Library" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step 1, you will find another folder named library, paste the unzip folder in it.
Non R studio Users
First get your default library locations by command ".libPath" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step 1, you will find another folder named library, paste the unzip folder in it.
I was also getting this error while trying to run the 'ggplot' function from the ggplot2 package. After trying the suggestions posted here and elsewhere (checking file paths, restarting R, clearing out my environment, etc.) and encountering several other cryptic error messages, it turned out that I needed to download the latest version of base R for Windows (v3.4.1) and update my version of R-Studio to the latest version also (v1.0.153).
After doing this my 'ggplot' function was working again and I was able to render my figure from R Studio without any further issues.
I was also getting this message when trying to use ggplot. I first updating both my R for Windows to 3.4.3. Then updating R studio to version 1.1.423; then, updating all of the packages and being sure to access the R version 3.4.3 from R studio, I still got the message. None of these things fixed the error. I was ready to give up until I noticed that I was calling library(ggplot) and had ggplot::ggplot in my code. THIS WAS THE PROBLEM. I changed it to library(ggplot2) and the instance to ggplot2::ggplot(...). THIS FIXEd the problems.
I was facing a similar issue, and I simply installed the said package. It's working perfectly for me.

Error in loadNamespace(name) : there is no package called 'Rcpp'

I am trying to embed RInside to my application on win7 64-bit system but when I initialize an RInside:
Rin = new RInside(argc, argv);
the following message appears:
Error in loadNamespace(name) : there is no package called 'Rcpp'
This error only occurs with Windows.
I think you get that issue when your .libPaths() differ--in other words run the .libPaths() function to see the paths stored by R for its use. Then check where RInside is installed, and make sure Rcpp is installed there too. It is a setup issue.
In other words, it should work if you have Rcpp and RInside installed where the basic R libraries are. Otherwise you have to tell the (embedded) R session about the other location (and before it starts).
There are more Windows users on the list, so you could try asking on rcpp-devel.
First get your default library locations by command ".Library" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step1.
Now you are ready to install packages which have dependencies on Rcpp.
Dirk is right in this case, BUT if the .libPaths() does not work, then please also check if you have the latest packages.
I am posting this as an ancillary answer backup which I ran into with the shiny package backend switch of their code needing Rcpp!
In this case of getting the "no package" error message, I fixed it by:
Selecting devtools package and then using this line below. (if you don't have devtools then get it with install.packages("devtools")
devtools::install_github("rstudio/shiny")
The development version of the package handled this better, and added the package as a dependency.
Mods - I realize this is an answer to an old question, but I might help others not wasting an hour like I just did.
You might find it easy if the answers are for both R studio users and non R studio users.
R Studio users
First get your default library locations by command ".Library" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step 1, you will find another folder named library, paste the unzip folder in it.
Non R studio Users
First get your default library locations by command ".libPath" in R.
Get Rcpp package from https://cran.r-project.org/web/packages/Rcpp/index.html.
Unzip and copy folder "Rcpp" to your default library locations obtained from step 1, you will find another folder named library, paste the unzip folder in it.
I was also getting this error while trying to run the 'ggplot' function from the ggplot2 package. After trying the suggestions posted here and elsewhere (checking file paths, restarting R, clearing out my environment, etc.) and encountering several other cryptic error messages, it turned out that I needed to download the latest version of base R for Windows (v3.4.1) and update my version of R-Studio to the latest version also (v1.0.153).
After doing this my 'ggplot' function was working again and I was able to render my figure from R Studio without any further issues.
I was also getting this message when trying to use ggplot. I first updating both my R for Windows to 3.4.3. Then updating R studio to version 1.1.423; then, updating all of the packages and being sure to access the R version 3.4.3 from R studio, I still got the message. None of these things fixed the error. I was ready to give up until I noticed that I was calling library(ggplot) and had ggplot::ggplot in my code. THIS WAS THE PROBLEM. I changed it to library(ggplot2) and the instance to ggplot2::ggplot(...). THIS FIXEd the problems.
I was facing a similar issue, and I simply installed the said package. It's working perfectly for me.

Installing R packages on Windows 7

On Windows 7 x64, I've got version 3.0.0 of R installed. Further, I've also set the environment variable R_LIBS_USER to point to a network drive. In rgui.exe, executing:
Sys.getenv("R_LIBS_USER")
outputs the same value that I previously set above. Also from R, installing packages into the personal library pointed to by R_LIBS_USER works fine. So far, so good.
With version 0.97.551 of RStudio installed, executing the same code above through RStudio also outputs the same value (as expected). However, from RStudio, my attempts at installing packages into the personal library fails. The error message effectively states that RStudio is unable to write to the personal library defined by R_LIBS_USER.
Before posting to stackoverflow, I checked the support forum for RStudio (http://support.rstudio.org/help/discussions/problems/4608-change-personal-library-for-installing-packages) where an admin states that the problem has to do with R and not RStudio. The admin goes on to reference the RStudio document generated by code
?.libPaths
in the RStudio IDE. The admin also provides additional guidance through link http://support.rstudio.org/help/kb/troubleshooting/getting-help-with-r.
After reviewing the IDE-generated document and forum link, I've determined that my environment is set up correctly. And yet, RStudio still fails.
Has anyone been able to get RStudio personal library working with a filesystem location other than the defaults?
I should clarify my needs a bit more. The environment to which this application will eventually be deployed prohibits normal users from running RStudio as administrators, hence the focus on R_LIBS_USER personal library. So although I know this would work, it is not a realistic option for me.
What I need is for RStudio to exclusively write to R_LIBS_USER and not attempt to also write to R_HOME (my assumption of what I think it is actually attempting to do.)
Add a line .libPaths("~/your-lib-path-here") to your .Rprofile and restart R. .libPaths() lets you write as well as read the the set of default libraries.
Alternately, if you can control the installation commands (i.e. you need your library to be available but it doesn't have to be the default), most R commands such as install.packages have a lib parameter that lets you manually specify the library to install to.
You might consider using an R package management system such as Packrat, which automates the job of installing your application's dependencies to a private library without you having to set it up manually. (Full disclosure, I'm a contributor to this package.) It works under RStudio.

Resources