Can`t install datasets in R, not cvs and not xlsx - r

I am new to RStudio. And it was working well, about a week ago my computer update the new version of the system. And from this moment R doesnt work like before. I am trying to load at datasets in .xlsx and .cvs - it doesn`t work. R write like this:
** Installing R Package Dependencies for Excel Import: `'readxl', 'Rcpp'`
[1/5] Installing cellranger...
�������������� � utils::install.packages("cellranger", repos = "https://cran.rstudio.com/") :
'lib = "C:/Program Files/R/R-4.0.2/library"' is not writable
������ � utils::install.packages("cellranger", repos = "https://cran.rstudio.com/") :
unable to install packages
������: sourceWithProgress -> eval -> eval -> <Anonymous>
���������� �����������
I trying to install xlsx packages, it writes like this:
`install.packages("xlsx")`
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Warning in install.packages :
'lib = "C:/Program Files/R/R-4.0.2/library"' is not writable
Warning in install.packages :
не могу создать каталог 'C:\Users\Lina\OneDrive\?????????' по причине 'Invalid argument'
Error in install.packages : unable to create ‘C:/Users/Lina/OneDrive/?????????/R/win-library/4.0’
if somebody can help me?

Since you appear to be a Windows user, I can offer two pieces of advice.
First, make sure your R installation is in a location that you have write permissions to. In some Windows OS, the Program Files locations are by default locked down. If the computer is yours, you should be able to change the permissions to the R folder. How to do so will vary a little by your windows version, so I will not provide more instructions. One other thing you can try is to set R and RStudio to "Run as administrator".
Second, OneDrive is a bad place to put your R installation or your R packages. OneDrive does not support all filenames and file extensions. R and its packages will generate a number of unsupported files, and you will continually be notified that something will not sync and that you should do something about it.
On a Windows machine, I generally install R and set up the library at C:\R where I have appropriate permissions.

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.

Unable to install any packages on R

I am trying to install packages for a spatial data course however each package I try install to R I get this same error message
Warning in install.packages :
'lib = "C:/Users/chris/OneDrive/Documents/R/win-library/3.4"' is not writable
I have made a folder under R in documents for 3.4.
I also get this error message;
cannot create dir 'C:\Users\chris\OneDrive\Documents\R\win-library\3.4\file2d1c49893057', reason 'No such file or directory'
Error in install.packages : unable to create temporary directory ‘C:\Users\chris\OneDrive\Documents\R\win-library\3.4\file2d1c49893057’
I don't understand whether I have to create a new directory before I install an R package or if I have a setting that prevents it from being able to install packages?
I have installed packages before/had R for 2 years and never had this issue....

Install multiple packages in R with dependencies and offline

For me to install a package A in R I need another 64 packages (these packages depend on each other). I downloaded all the packages in a folder, including package A (I did this on a computer with internet access). I tried the following:
library(tools)
write_PACKAGES("/home/user/Documents/packages to install/")
after,
install.packages ("StarBioTrek", contriburl = "file: /// home / user / Documents / packages to install /", verbose = "progress report")
but the following message appeared to me:
Error in install.packages: error reading from connection
How can I install Package A on another computer (without internet access)?
Thanks in advance

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.

Resources