Installing ggplot on SolusOS - r

I've installed R and Rstudio on a netbook running SolusOS (Debian) and those installations seem to be working OK. However I've had no success with installing the R package ggplot2 .
I've tried the stock command from within R and in Rstudio of:
install.packages(“ggplot2”)
also:
install.packages(“ggplot2”, dependencies=TRUE)
both as user and with root privileges. But when I go to a mirror I get:
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package 'ggplot2' is not available
I've also set up a /data/Rpackages/ directory as recommended in http://www.r-bloggers.com/installing-r-packages/ but this has also not been successful.
If anyone has advice on what else to try or indeed to how remove and reinstall R and start again I would be grateful.

Related

Sharing R library's between linux subsystem for windows and windows

I have a window ubuntu VM. I have R installed in the windows. I recently tried to call an R script in my ubuntu but it told me the library is not installed. Is there a way to tell ubuntu's R installation to use my windows R libraries so I don't have to reinstall them all on ubuntu?
StratifiedFullModel/SecondRun$ Rscript StratifiedFullModels.R
Loading required package: car
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages(x, dependencies = TRUE) :
'lib = "/usr/local/lib/R/site-library"' is not writable
Error in install.packages(x, dependencies = TRUE) :
unable to install packages
Calls: lapply -> FUN -> install.packages
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘car’
Execution halted
This is strange because the script is set up to check for packages, one of which is car, and either load them or install them. I suspect it is not doing so because of some problem with permissions.
This is problematic because I may want to write scripts that just auto install packages without me having to manually do it which would be time consuming if I share a script with a colleague or if I transfer work to a new machine.
Edit: Tried turing R on in ubuntu and running install.packages("car") returned the following error:
> install.packages("car")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("car") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel) cancel
Error in install.packages("car") : unable to install packages
>
I just cancelled the install. I think this confirms my suspicion that there is an issue with the permissions.
The Linux and Windows installations of R are completely separate, and that includes packages. That said, you can run the Windows version from within WSL, so you don't need to maintain duplicate environments.
Here's a screenshot of both Linux and Windows R running on my machine, from within WSL:
Note that this answer is based on my experience with WSL rather than R specifically. I'd welcome updates or more authoritative answers from anyone who has used R under WSL.
I believe you are going to run into problems if you attempt to use, at least, some Windows R libraries from WSL. A 'pure-R' library should work, in theory, but it looks to me from some quick searches that R can also include compiled code which would be platform-specific. In this case, if any libraries end up in native-code, then a Windows library is going to have issues when called from Linux with Linux path structures (e.g. /home instead of C:\Users), processes, and other OS constructs.
As for the permissions issue, R is using a default library directory (under /usr/local/lib/R/site-library) that is only writable by root. It appears that you can change the library installation directory with something like:
> install.packages("car", lib="/home/<username>/.local/lib/R/site-library/")
Of course, you'll need to create that directory first. See this page for more details.

Cannot install tsDyn package in RStudio, 'mnormt' doesn't exist

I am trying to install the tsDyn package on my Macbook Pro running MacOSX Catalina version 10.15.2. in RStudio (v.1.3.959), running R (v.4.0.1). I get the following error:
ERROR: compilation failed for package ‘mnormt’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/mnormt’
Warning in install.packages :
installation of package ‘mnormt’ had non-zero exit status
I tried installing 'mnormt' myself, as well as deleted all irrelevant packages manually to get rid of any possible older versions that may be interfering with the 'tsDyn' package, but nothing seems to be working.
The 'tsDyn' package seems to be installing otherwise, but I cannot call the function 'VECM' because it R states that it does not exist.
Any help would be much appreciated.
If you are using Anaconda, inside Environments search for "r-mnormt" and install from there. Also you can try inside RStudio:
install.packages("r-mnormt")
It should work now.

Error installing packages in Rstudio

I have R 3.2.2 setup installed in my system,with RStudio version 0.99.489. When I tried to install rJava package,
install.packages("rJava")
I am getting following Error:
Warning in install.packages :
downloaded length 4878 != reported length 200
Error in install.packages : subscript out of bounds
But if I run the below command before installing any package,it works fine, but I don't want to do this every time I install a package.
options(repos=structure(c(CRAN="http://cran.us.r-project.org")))
You can stick the line you want executed at every startup in your .Rprofile file which should be in your home directory. I have 3.2.3 version of R and that worked; however I do get a warning message about using a non-http version of the site.
Similarly to you, I was finding the original repository the system was using was failing to install the packages--not finding the package or downloading a file with too few bytes, perhaps because of a transient problem. You might want to consider not putting this in your .Rprofile file or commenting the line outin case this is a temporary workaround.

Error when installing R package using Rstudio

I want to install http://cran.r-project.org/src/contrib/Archive/mecdf/ using RStudio but when I use
> install.packages('C:\\Users\\jandre\\Desktop\\mecdf_0.6.1.tar.gz', repos=NULL, type="source")
I get this error:
Installing package into ‘C:/Users/jandre/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"C:/Program Files/R/R-3.1.1/bin/x64/R" CMD INSTALL -l "C:\Users\jandre\Documents\R\win-library\3.1" "C:/Users/jandre/Desktop/mecdf_0.6.1.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/jandre/Desktop/mecdf_0.6.1.tar.gz’ had non-zero exit status
This occurs in every package I want to install using the tar.gz file. I'm on Win7 x64. RStudio Version 0.98.1028
Can't think of a way to fix this at the moment -- sorry -- but the R administration manual says explicitly:
Note that installing R into a directory whose path contains spaces is not supported, and at least some aspects (such as installing source packages) will not work.
I don't know why this doesn't bite people much more often, given that C:/Program Files/... seems like a relatively normal place to install things on Windows.
I would also expect that the double quotation marks around your R executable name ("C:/Program Files/R/R-3.1.1/bin/x64/R") in the system call should have protected you from this problem ... ?
I had the same error message with the installation of some packages(under Windows 10 OS with R and Rstudio).
It seems that the R software (not R Studio) is dealing with the library where package are installed.
I uninstalled R and Rstudio and installed it a path without space (ex: C:\Program\R).I tried to load the packages that previously failed and it seemed to fix the problem.

LOCAL R Package not running because of missing doMC dependancy

I am trying to get a local package to work but it depends on doMC which is only available for Mac and I don't have a Mac. Is there any way I can still make the package work? I use the following code:
install.packages("~/R/AMT/Code/CLVTools_1.0.5.tar.gz",repos=NULL,type="source")
After running the code I get the following error message:
Installing package into ‘C:/Users/alexa_000/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)ERROR: dependency 'doMC' is not available for package 'CLVTools'
* removing 'C:/Users/alexa_000/Documents/R/win-library/3.0/CLVTools'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\alexa_000\Documents\R\win-library\3.0" "C:/Users/alexa_000/Documents/R/AMT/Code/CLVTools_1.0.5.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/alexa_000/Documents/R/AMT/Code/CLVTools_1.0.5.tar.gz’ had non-zero exit status
Does anyone have any ideas how to run the package anyways?
Any kind of help highly appreciated
Based on the documentation, that package should run on any Unix system, not just OS X.
Your best bet is to install a virtual machine and put a Linux distro on it, or dual-boot your Windows PC with Linux.
More generally, if you are going to be doing a lot of data processing with open source tools like R, Linux is your friend.

Resources