install xlsx and xlsxjars in R 3.2.0 - r

Since today I am using the R Version 3.2.0 for statistical analysis. Today I try to install the packages "xlsx" and "xlsxjars" for my new installation but it didn't work. Every time I try to install the packages (install.packages("xlsx")) I get the following error message:
Warning in install.packages :
downloaded length 9351168 != reported length 9485172
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/xlsx_0.5.7.zip'
Content type 'application/zip' length 400857 bytes (391 KB)
downloaded 391 KB
Warning in install.packages :
error 1 in extracting from zip file
Warning in install.packages :
cannot open compressed file 'xlsxjars/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the Connection`
The problem only take place when I try to install the xls-packages. Other packages can be installed smoothly without any problems.
I hope there is anyone out there who had already installed the aforesaid packages in R Version 3.2.0 and can give me a short advice how to install the packages in the new R Version?

First,
setInternet2(use=TRUE)
Then install necessary packages individually:
install.packages('rJava')
install.packages('xlsxjars')
install.packages('xlsx')

Related

Can't install R packages, getting error '& was unexpected at this time.'

I have a strange error which seems like it's not coming through R, but through powershell (at least based on the terminal-esque style). I just reinstalled R due to some issues, and it's been working alright. I installed the most recent R 4.2.2, then the most recent Rstudio, but then that Rstudio couldn't find my version of R even when I directed it to the folder. I gave in and uninstalled Rstudio and installed the version right before it. This seemed to work okay, until now when I'm trying to install packages (both through install.packages, and through devtools). It gives the error:
> install.packages('RSQLite')
Installing package into ‘C:/Users/Ryan/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
RSQLite 2.2.19 2.2.20 TRUE
installing the source package ‘RSQLite’
trying URL 'https://cran.rstudio.com/src/contrib/RSQLite_2.2.20.tar.gz'
Content type 'application/x-gzip' length 3745301 bytes (3.6 MB)
downloaded 3.6 MB
& was unexpected at this time.
Warning in install.packages :
installation of package ‘RSQLite’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\Ryan\AppData\Local\Temp\Rtmp4uP1BH\downloaded_packages’
or it gives:
> devtools::install_github("r-dbi/RSQLite")
Downloading GitHub repo r-dbi/RSQLite#HEAD
── R CMD build ───────────────────────────────────────────────────────────────────────
& was unexpected at this time.
Error: Failed to install 'RSQLite' from GitHub:
! System command 'Rcmd.exe' failed
I've previously installed packages on this R version and it just stopped working now. I'm no expert in R and I would appreciate any help or guidance. If you need any more information let me know and I'll update the post.
I'm running Windows 11.

Unable to access libraries in RStudio but not in R

I am facing a problem in RStudio when installing and using packages. I'm very very new to it so please bear with me while I describe it:
This is a new R and Rstudio installation in my PC, R version 4.1.2. For remote work due to life stuff. I usually run these same commands in my job computer with no problem (always in administrator mode).
However, when installing "readxl" to open an excel file:
> install.packages("readxl")
Installing package into ‘C:/Program Files/R/R-4.1.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/readxl_1.3.1.zip'
Content type 'application/zip' length 1717234 bytes (1.6 MB)
downloaded 1.6 MB
package ‘readxl’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘readxl’
Warning in install.packages :
problem copying C:\Program Files\R\R-4.1.2\00LOCK\readxl\libs\x64\readxl.dll to C:\Program Files\R\R-4.1.2\readxl\libs\x64\readxl.dll: Permission denied
Warning in install.packages :
restored ‘readxl’
The downloaded binary packages are in
C:\Users\Andrés RM\AppData\Local\Temp\Rtmp2RhFPr\downloaded_packages
I've read about deleting 00lockto avoid this problem but I can't find the file anywhere.
And when i check my libraries using libpath()
> .libPaths()
[1] "C:/Program Files/R/R-4.1.2" "C:/Program Files/R/R-4.1.2/library"
Then, if I want to load the library
> library(readxl)
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/my_user/Documents": The system cannot find the path specified
It returns a path that I never specified in the first place and where I don't keep any other R library.
If i try to load an excel file:
R_meristem_measures <- read_excel("C:/Users/my_user/Desktop/R meristem measures.xlsx")
Error: Evaluation error: zip file 'C:\Users\my_user\Desktop\R meristem measures.xlsx' cannot be opened.
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/Andrés RM/Desktop/R meristem measures.xlsx": The system cannot find the path specified
After this, .libPaths()keeps returning the same results.
This happens with some other packages that I use daily (in my other computer) and the warning is the same.
However, I just tried to run this same code in native R (R x64 4.1.2) and it went perfect with no issues.
I am at a loss here. Among others I've tried sys.setenv(R_LIBS_USER)and also changing the same environment variables from the Control panel.R_LIBS="C:/R/library"also does not work.
At work I am using R 4.0 and libPaths()returns
.libPaths()
[1] "C:/Users/my_user/Documents/R/win-library/4.0" "C:/Program Files/R/R-4.0.2/library"
which is expected since my_user/etc is where i keep my packages.
Is this a problem with my computer or with something particular from RStudio? R itself works perfect but is a pain to use and I would like to use RStudio even if I can run my stuff in R console.
Thanks to everyone

R will not install packages

RStudio is not letting me install any new packages. As an example, I attempted to install "rio" today and got the following message:
install.packages("rio")
Installing package into ‘C:/Users/kjl5444/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependency ‘openxlsx’ is not available
There is a binary version available but the source version is later:
binary source needs_compilation
rio 0.4.0 0.5.5 FALSE
installing the source package ‘rio’
trying URL 'https://cran.rstudio.com/src/contrib/rio_0.5.5.tar.gz'
Content type 'application/x-gzip' length 390824 bytes (381 KB)
downloaded 381 KB
'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-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\kjl5444\Documents\R\win-library\3.2" C:\Users\kjl5444\AppData\Local\Temp\RtmpaQwlLL/downloaded_packages/rio_0.5.5.tar.gz' had status 1
Warning in install.packages :
installation of package ‘rio’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\kjl5444\AppData\Local\Temp\RtmpaQwlLL\downloaded_packages’
> library(rio)
Error in library(rio) : there is no package called ‘rio’
Any help on deciphering and fixing this error?
While trying to install the rio package in Microsoft windows. I faced an error. In order to resolve that issue, I googled and came to this page.
I know this post is a bit old post but thought to share it for those who face a similar issue in installing this package.
Similar to this post:
Error: "there is no package called ..." and trying to use install.packages to solve it
I could only install rio when I used the command:
install.packages('rio', dependencies = TRUE, repos='http://cran.rstudio.com/')
Perhaps it can help you successfully install the required packages as it ensures that dependencies are also installed along with the required package.

Rcpp installation

I just updated R to 3.4.0 and RStudio to 1.0.143, and I reinstalled some packages. Everything was ok except for Rcpp (and packages which require Rccp), I got this :
> install.packages("Rcpp")
Warning in install.packages :
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES.rds': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'
There is a binary version available but the source version is later:
binary source needs_compilation
Rcpp 0.12.10 0.12.11 TRUE
Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package ‘Rcpp’
trying URL 'https://cran.rstudio.com/src/contrib/Rcpp_0.12.11.tar.gz'
Content type 'application/x-gzip' length 2485092 bytes (2.4 MB)
downloaded 2.4 MB
'\\CXXXX0001\Users\RXXXXn'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
'\\CXXXX0001\Users\RXXXXn\R\R-3.4.0' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"//CXXXX0001/Users/RXXXn/R/R-3.4.0/bin/x64/R" CMD INSTALL -l "\\CXXXX0001\Users\RXXXXn\R\R-3.4.0\library" C:\Users\RXXX~1\AppData\Local\Temp\RtmpmOL8r0/downloaded_packages/Rcpp_0.12.11.tar.gz' had status 1
Warning in install.packages :
installation of package ‘Rcpp’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\RXXXXn\AppData\Local\Temp\RtmpmOL8r0\downloaded_packages’
I restarted my R session before doing this, so there should be no conflict of loaded packages.
What can I do ?
EDIT after user3293236 comment
I also have a problem with devtools package...
> install.packages("devtools")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/devtools_1.13.1.zip'
Content type 'application/zip' length 440923 bytes (430 KB)
downloaded 430 KB
package ‘devtools’ successfully unpacked and MD5 sums checked
Warning in install.packages :
unable to move temporary installation ‘\\CXXXX0001\Users\RXXXXn\R\R-3.4.0\library\file16401ac3a13\devtools’ to ‘\\CXXXX0001\Users\RXXXXn\R\R-3.4.0\library\devtools’
The downloaded binary packages are in
C:\Users\RXXXXn\AppData\Local\Temp\RtmpmOL8r0\downloaded_packages
> library(devtools)
Error in library(devtools) : aucun package nommé ‘devtools’ n'est trouvé
I encountered the same issue while trying to set up someone else's computer. Brand new R installation (R version 3.4.1) but R was installed in a OneDrive folder. I also thought it was a permissions thing (as #nrussell commented) as the error was the same ... unable to move temporary installation ....
I had no issue installing devtools as normal (or any other packages) and even with Rtools installed Rcpp would not install by install.packages("Rcpp")`. Interestingly,
install.packages("Rcpp", type = 'source')
Did work after some compiling. Strange...
I had similar problem so, I installed a previous Rcpp release and worked.
install_version("Rcpp", version = "1.0.3", repos = "http://cran.us.r-project.org")
What can you do? I would start by reading the error messages.
It clearly showed you that you are offered a different source and binary version. For the former you need tools. That is abundantly documented.
And by tomorrow CRAN will also have a new binary version for you. But with a new release made hours ago, you need to wait a moment. Or make your system capable of installing from source.

Error while trying to install R packages

I tried to install a package in R by typing:
install.packages("prob")
But got error:
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/prob_0.9-5.zip'
Content type 'application/zip' length 707050 bytes (690 Kb)
opened URL
downloaded 690 Kb
Warning in install.packages :
write error in extracting from zip file
Warning in install.packages :
cannot open compressed file 'gss/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection
How can I resolve it? It only happens with some packages, not all.
The error is suggesting that the package requires another package gss that is not available. That package is not in any of the dependencies but perhaps one of the dependencies requires it in turn. prob's description says:
Version: 0.9-5
Depends: combinat, fAsianOptions, hypergeo, VGAM
When you look at the gss description on CRAN, it says:
Reverse depends: gsscopu, STAR
Reverse imports: fBasics, timeSeq
So I'm guessing that fAsianOptions requires fBasics and that fBasics needs gss. If I'm right, then you should try installing gss first, and then install prob.

Resources