Issues installing "forecast" package in R - r

I am trying to install the forecast package in R via: install.packages('forecast'), nevertheless this is not working.
The result:
There is a binary version available but the source version is later:
binary source needs_compilation
forecast 8.2 8.3 TRUE
Do you want to install from sources the package which needs compilation?
Not sure what to answer here, 'yes' or 'no'. If I answer 'no', the result is:
trying URL 'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/forecast_8.2.tgz'
Content type 'application/x-gzip' length 2204227 bytes (2.1 MB)
==================================================
downloaded 2.1 MB
tar: Failed to set default locale
The downloaded binary packages are in
/var/folders/qn/syx5z5tj4s5075wwmrrd3hbr0000gn/T//RtmpTBDqVs/downloaded_packages
If I type 'yes' some additional items are installed and I receive one error note:
Warning in install.packages :
installation of package 'forecast' had non-zero exit status
Unfortunately I cannot proceed with the necessary functions that this package provides. Thanks for any suggestions.

I had the same problems, changing primary CRAN repository works for me
Tools > Global Options > Packages

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.

Installing Source Packages

I'm unable to install certain source packages in R. Until now I've just made do with using binary, however the in trying to use rmarkdown this workaround isn't possible (RMarkdown requires updated version to work).
I don't understand what this issue is. I've installed the correct version of RTools (3.5) for the R (3.6.3) that I'm using, but that alone hasn't fixed it.
Am using Windows 10.
Would really appreciate pointing in the right direction. The error message looks like this (for all packages that fail):
** Installing R Package Dependencies for R Markdown: 'rmarkdown', 'stringi'
[1/4] Installing bslib...
Installing package into 'C:/Users/paulb/OneDrive/Documents/R/win-library/3.6'
(as 'lib' is unspecified)
also installing the dependency 'htmltools'
There are binary versions available but the source versions are later:
binary source needs_compilation
htmltools 0.5.1.1 0.5.2 TRUE
bslib 0.2.4 0.3.1 FALSE
installing the source packages 'htmltools', 'bslib'
trying URL 'https://cran.rstudio.com/src/contrib/htmltools_0.5.2.tar.gz'
Content type 'application/x-gzip' length 124510 bytes (121 KB)
==================================================
downloaded 121 KB
trying URL 'https://cran.rstudio.com/src/contrib/bslib_0.3.1.tar.gz'
Content type 'application/x-gzip' length 4908277 bytes (4.7 MB)
==================================================
downloaded 4.7 MB
Error: object 'R' not found
Execution halted
First we have to install r version and RStudio then install recommend packages.
Use below youtube link in Hindi.
https://www.youtube.com/watch?v=dgmCiZvdI_4

Different size assigned

I am trying to install graphite package from Bioconductor. However I keep getting cannot allocate vector of size XXX, despite being able to create an object of a bigger size.
> BiocManager::install("graphite")
Bioconductor version 3.8 (BiocManager 1.30.3), R 3.5.1 (2018-07-02)
Installing package(s) 'graphite'
trying URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/graphite_1.28.0.tar.gz'
Content type 'application/x-gzip' length 4937193 bytes (4.7 MB)
==================================================
downloaded 4.7 MB
* installing *source* package ‘graphite’ ...
** R
Error : cannot allocate vector of size 844.3 Mb
ERROR: unable to build sysdata DB for package ‘graphite’
* removing ‘/usr/lib/R/site-library/graphite’
The downloaded source packages are in
‘/tmp/RtmpeRdRny/downloaded_packages’
Warning message:
In install.packages(pkgs = doing, lib = lib, repos = repos, ...) :
installation of package ‘graphite’ had non-zero exit status
> print(object.size(runif(129999999)), units = "Mb")
991.8 Mb
It doesn't work even if I start a new session with R --vanilla. The problem might be related to building the sysdata DB for the package. But I don't know how to solve it (as a user). How can I install it?
The problem seems to be on while making the package. I posted another error I got into the support site of Bioconductor and the author answered fixing the bug on version 1.29.1 (devel version of the package).
So the solution is to install the latest version of the package:
remotes::install_git("https://git.bioconductor.org/packages/graphite", ref = "master")

R does not find "update.packages"

I am running R in version 3.4.1 under Windows 7 64-bit. When I give update.packages(ask=FALSE) the routine starts, identifies some packages to be updated, downloads packages, and then returns:
Error in update.packages(ask = FALSE) :
could not find function "update.packages"
Execution halted
I cannot find a reason for this problem. I just installed the newest version of R.
Complete output: I add the complete output. Maybe the problem is hidden in here, see e.g. the Warning messages. I shortened some paths (...). The problem seems to be with package knitr?
There are binary versions available but the source versions are later:
binary source needs_compilation
knitr 1.16 1.17 FALSE
rlang 0.1.1 0.1.2 TRUE
Binaries will be installed
trying URL 'https://cran.wu.ac.at/bin/windows/contrib/3.4/rlang_0.1.1.zip'
Content type 'application/zip' length 466606 bytes (455 KB)
downloaded 455 KB
package ‘rlang’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\...
installing the source package ‘knitr’
trying URL 'https://cran.wu.ac.at/src/contrib/knitr_1.17.tar.gz'
Content type 'application/x-gzip' length 769923 bytes (751 KB)
downloaded 751 KB
Error in update.packages(ask = FALSE) :
could not find function "update.packages"
Execution halted
The downloaded source packages are in
‘C:\Users\...’
Warning messages:
1: running command '"C:/PROGRA~1/R/R-34~1.1/bin/x64/R" CMD INSTALL -l "N:\RLibrary" C:\Users\...' had status 1
2: In install.packages(update[instlib == l, "Package"], l, repos = repos, :
installation of package ‘knitr’ had non-zero exit status

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.

Resources