Trouble with downloading certain packages from github in R - r

I get an error when I try to download and install some packages from github on my Mac, e.g. lubripack. How do I locate what the error actually means? And how to solve it?
I run: install_github("Espanta/lubripack"). I have tried with different libpaths and with force=TRUE.
This is from the console:
checking for file
‘/private/var/folders/nc/vs1bpbqn095bbx84qcwwm4bm0000gn/T/RtmpMn5l2o/remotes8cb7b2460a1/Espanta-lubripack-b1dd9ee/DESCRIPTION’
... OK preparing ‘lubripack’: checking DESCRIPTION meta-information
... OK checking for LF line-endings in source and make files and shell
scripts checking for empty or unneeded directories building
‘lubripack_0.1.tar.gz’ Error: Failed to install 'lubripack' from
GitHub: (converted from warning) line 1 appears to contain an
embedded nul

You may not need to worry about installing the package from github - since the package only contains a single function, I'd simply copy the code for that function and use it (citing the author if/when appropriate).
lubripack <- function(...,silent=FALSE){
#check names and run 'require' function over if the given package is installed
requirePkg<- function(pkg){if(length(setdiff(pkg,rownames(installed.packages())))==0)
require(pkg, quietly = TRUE,character.only = TRUE)
}
# list of packages to install and load
packages <- as.vector(unlist(list(...)))
if(!is.character(packages))stop("No numeric allowed! Input must contain package names to install and load")
if (length(setdiff(packages,rownames(installed.packages()))) > 0 )
install.packages(setdiff(packages,rownames(installed.packages())),
repos = c("https://cran.revolutionanalytics.com/", "http://owi.usgs.gov/R/"))
res<- unlist(sapply(packages, requirePkg))
if(silent == FALSE && !is.null(res)) {cat("\nBellow Packages Successfully Installed:\n\n")
print(res)
}
}
It works for me even on R 4.0.2
lubripack(list("dplyr"))
Bellow Packages Successfully Installed:
dplyr
TRUE
And for reference
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.0.0 gtools_3.8.2
loaded via a namespace (and not attached):
[1] crayon_1.3.4 R6_2.4.1 lifecycle_0.2.0 magrittr_1.5 pillar_1.4.6 rlang_0.4.7 rstudioapi_0.11 vctrs_0.3.2
[9] generics_0.0.2 ellipsis_0.3.1 tools_4.0.2 glue_1.4.1 purrr_0.3.4 compiler_4.0.2 pkgconfig_2.0.3 tidyselect_1.1.0
[17] tibble_3.0.3

Try this
First run
install.packages("remotes")
once done
Run this : -
remotes::install_github("Espanta/lubripack")
Ignore the warning
I am able to load the library
I am not sure if this library is up to date like Dirk Eddelbuettel mentioned
But its loading

Related

Error installing tidyr on Ubuntu 18.04 & R 4.0.2

In trying to install the package tidyverse, I get errors in the installation of dependency tidyr.
Here is the tail of the message I get:
cpp11.cpp:31:100: error: ‘unmove’ is not a member of ‘cpp11’
return cpp11::as_sexp(simplifyPieces(cpp11::unmove(cpp11::as_cpp<cpp11::list>(pieces)), cpp11::unmove(cpp11::as_cpp<int>(p)), cpp11::unmove(cpp11::as_cpp<bool>(fillLeft))));
^~~~~~
cpp11.cpp:31:138: error: ‘unmove’ is not a member of ‘cpp11’
return cpp11::as_sexp(simplifyPieces(cpp11::unmove(cpp11::as_cpp<cpp11::list>(pieces)), cpp11::unmove(cpp11::as_cpp<int>(p)), cpp11::unmove(cpp11::as_cpp<bool>(fillLeft))));
^~~~~~
/usr/lib/R/etc/Makeconf:176: recipe for target 'cpp11.o' failed
make: *** [cpp11.o] Error 1
ERROR: compilation failed for package ‘tidyr’
* removing ‘/home/xxx/yyy/tidyr’
Warning in install.packages :
installation of package ‘tidyr’ had non-zero exit status
To my naive eye, it would seem the issue lies with cpp11. I saw a similar question regarding tidyr installation error due to cpp11 compilation error (R tidyr package installation failed due to cpp11 compilation error (expansion pattern x contains no argument packs)), but it was for a RHEL system.
I have the latest version of gcc/c++ installed on my system (4:7.4.0-1ubuntu2.3). The latest version of system dependencies libcurl4-openssl-dev libssl-dev libxml2-dev are also installed.
Here is the output of sessionInfo():
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] rstudioapi_0.11 magrittr_1.5 usethis_1.6.1 devtools_2.3.1 pkgload_1.1.0 R6_2.4.1 rlang_0.4.7 fansi_0.4.1 tools_4.0.2
[10] pkgbuild_1.1.0 sessioninfo_1.1.1 cli_2.0.2 withr_2.2.0 ellipsis_0.3.1 remotes_2.2.0 assertthat_0.2.1 digest_0.6.25 rprojroot_1.3-2
[19] crayon_1.3.4 processx_3.4.3 callr_3.4.3 fs_1.5.0 ps_1.3.3 curl_4.3 testthat_2.3.2 memoise_1.1.0 glue_1.4.1
[28] compiler_4.0.2 desc_1.2.0 backports_1.1.8 prettyunits_1.1.1
It looks like #hadley released an update to tidyr a few days ago, based on the new cpp11 package: https://github.com/tidyverse/tidyr/releases.
For some reason, this caused tidyr to not build for us.
Our (hopefully temporary!) workaround was like this:
(1) Remove dependency on tidyverse. Instead, explicitly depend on the subpackages( like dplyr/ggplot2/etc. )
(2) Install tidyr in the following way:
packageurl <- "https://cran.r-project.org/src/contrib/Archive/tidyr/tidyr_1.1.0.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
Looks like the following commit is addressing this, though not sure when it will be pushed to CRAN: https://github.com/r-lib/cpp11/commit/779669a4d0b07e9f9d9382114f44e4f6ff68eebb
I found the following here: https://github.com/tidyverse/tidyr/issues/1024
The workaround consists in downgrading cpp11 to version 0.1:
devtools::install_version("cpp11", version = "0.1", repos = "http://cran.us.r-project.org")
Based on the answers from #djacobs7, #mkamenet3, and #Leandro R. M. de Marco, I ended up implementing the following solution, which worked for me.
Removing the cpp11 package, which I had installed from cran.
Re-installing the cpp11 package, but this time from github, as it contains the commit mentioned by #mkamenet3.
devtools::install_github("r-lib/cpp11")
Installing tidyr normally
install.packages("tidyr")

Package ‘XXX’ was installed before R 4.0.0: please re-install it

I am using R 4.0.2.
I manually installed 2 packages from cfcdae and Stats5303lib from here. I followed the instruction here to download Rtools and use it to install packages above.
Problem is
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron") # runs fine
Sys.which("make") #works fine
make
"C:\\rtools40\\usr\\bin\\make.exe"
install.packages("Stat5303libs_0.7-5.zip",repos=NULL,type="source") # these all run fine
install.packages("cfcdae_0.8-4.zip",repos=NULL,type="source") # these all run fine
However, when I ran into problem below when I tried to run the libraries.
Error: package or namespace load failed for ‘cfcdae’:
package ‘cfcdae’ was installed before R 4.0.0: please re-install it
I tried below but still in vain.
update.packages(ask=FALSE, checkBuilt=TRUE)
Why is this happening? Is it because the package is too old?
Update:
As requested, i have changed my .libPaths() as below and updated the SessionInfo() as well.
> .libPaths()
[1] "C:/Users/UserME/Documents/R/win-library/4.0"
[2] "C:/Program Files/R/R-4.0.2/library"
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_Hong Kong SAR.1252 LC_CTYPE=English_Hong Kong SAR.1252
[3] LC_MONETARY=English_Hong Kong SAR.1252 LC_NUMERIC=C
[5] LC_TIME=English_Hong Kong SAR.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 rstudioapi_0.11 magrittr_1.5
[4] splines_4.0.2 MASS_7.3-51.6 tidyselect_1.1.0
[7] munsell_0.5.0 statmod_1.4.34 lattice_0.20-41
[10] colorspace_1.4-1 R6_2.4.1 rlang_0.4.6
[13] minqa_1.2.4 dplyr_1.0.0 tools_4.0.2
[16] grid_4.0.2 nlme_3.1-148 gtable_0.3.0
[19] ellipsis_0.3.1 lme4_1.1-23 tibble_3.0.1
[22] lifecycle_0.2.0 numDeriv_2016.8-1.1 crayon_1.3.4
[25] Matrix_1.2-18 nloptr_1.2.2.2 purrr_0.3.4
[28] ggplot2_3.3.2 vctrs_0.3.1 glue_1.4.1
[31] compiler_4.0.2 pillar_1.4.6 generics_0.0.2
[34] scales_1.1.1 boot_1.3-25 lmerTest_3.1-2
[37] pkgconfig_2.0.3
All packages need to be reinstalled under the new version (4.0). I had to first remove and then reinstall all the packages.
The following worked for me:
# check your package library path
.libPaths()
# grab old packages names
old_packages <- installed.packages(lib.loc = "/Library/Frameworks/R.framework/Versions/3.6/Resources/library")
old_packages <- as.data.frame(old_packages)
list.of.packages <- unlist(old_packages$Package)
# remove old packages
remove.packages( installed.packages( priority = "NA" )[,1] )
# reinstall all packages
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(list.of.packages,function(x){library(x,character.only=TRUE)})
This issue is likely to happen when R is reading from an old directory, e.g. pre R 4.0.x .
Here is a few possible ways to fix this:
Check your .libPaths() - R could be reading packages from a R 3.x.x library, which would produce the error you are getting. Alternatively, try creating a new library directory (this is very likely to fix the issue).
update.packages(ask=FALSE, checkBuilt=TRUE) (which you have already tried)
Remove previous installations of R, and their associated directories.
A zip file is a pre-built binary package for use on Windows, not a source package. Installing it with install.packages(*, type="source") won't make a difference. You'll need to contact the person/people who wrote these packages to build them again for R 4.0, or provide you with the real source -- this will usually be a .tar.gz file.
If you're having trouble with this issue while using renv, you may need to look at your renv cache. I had to delete mine to force my projects to use newly-installed versions of packages instead of the old ones.
In a similar situation, I renamed 'site-library' to 'old-site-library', made a new empty 'site-library' folder and proceeded from there successfully.
In case anyone runs into this error message when running revdepcheck::revdep_check(), what worked for me was deleting the /revdep/ folder in my R package's directory.
This code worked for me
tmp = as.data.frame(installed.packages())
max_version = max(as.numeric(substr(tmp$Built, 1,1)))
tmp = tmp[as.numeric(substr(tmp$Built, 1,1)) < max_version,]
lapply(tmp$Package, remove.packages)
lapply(tmp$Package, function(x) install.packages(x, dependencies = TRUE))

R package not available in batch mode

I have been running a bash script (under Ubuntu) that calls and runs some R scripts to plot some maps with ggplot2. As it is a production system I don't update any new R or package releases. But recently I tried to install plotly with an error message output.
Now, when trying to run the script (calling a php webpage trhough a browser; that was running fine for a lot of time) an error with crayon package halts and exits the script without plotting the maps.
'/usr/lib/R/bin/R --slave --no-restore --no-save --no-restore --file=./RAMS-mapa-onades-zones-manual.R'
Loading required package: sp
Loading required package: methods
Checking rgeos availability: TRUE
Error : .onLoad failed in loadNamespace() for 'pillar', details:
call: loadNamespace(name)
error: there is no package called 'crayon'
Error: package or namespace load failed for 'ggplot2'
Execution halted
But if I run from a terminal or with RStudio server crayon package is loaded, ggplot2 is also properly loaded, and the maps are produced.
crayon package (located at /home/meteo/R/i686-pc-linux-gnu-library/3.1) called as
library("crayon", lib.loc= c("/home/meteo/R/i686-pc-linux-gnu-library/3.1", "/usr/local/lib/R/site-library", "/usr/lib/R/library"))
R session info on Rstudio Server:
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu precise (12.04.5 LTS)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C LC_COLLATE=C LC_MONETARY=C LC_MESSAGES=C
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] crayon_1.3.4 rgdal_0.9-1 rgeos_0.3-8 raster_2.3-24 gpclib_1.5-5 mapproj_1.2-2 maps_2.3-9
[8] stringr_0.6.2 plyr_1.8.1 ggplot2_3.2.0 maptools_0.8-34 sp_1.2-3
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 magrittr_1.5 tidyselect_0.2.5 munsell_0.5.0 colorspace_1.2-4 lattice_0.20-33 R6_2.4.0
[8] rlang_0.3.4 dplyr_0.8.1 tools_3.2.2 gtable_0.1.2 withr_2.1.2 digest_0.6.8 lazyeval_0.2.2
[15] assertthat_0.2.1 tibble_2.1.3 purrr_0.3.2 glue_1.3.1 labeling_0.3 pillar_1.4.1 scales_1.0.0
[22] foreign_0.8-66 pkgconfig_2.0.2
Maybe there is a version conflict? How do I check?
what version of R is in /usr/lib/R/bin/R? Basically it appears you are in a slight "dependency hell" I would run /usr/lib/R/bin/R and check to see if crayon is installed there. #Alexis is correct though, it is not wise to mix versions like that. Let R handle library location unless you are trying to separate packages. Check the libraries for 3.2.2 and see if crayon is installed. you may have switched your R version since plotly depends on R >=3.2.0 https://cran.r-project.org/web/packages/plotly/
I think the easy fix would be to correct your .libpaths() i.e not call the 3.1 library and install the correct version of the packages you need.
OR
switch from R 3.2 back to R 3.1

R refers to non exisiting files during R CMD check

I want to R CMD check with RStudio my package (for this question I call it pkg). But I get the following error message:
* preparing 'pkg':
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ...Error in find_vignette_product(name, by = "weave", dir = docdir, engine = engine) :
Failed to locate the 'weave' output file (by engine 'utils::Sweave') for vignette with name 'my-vignette'. The following files exist in directory 'C:/Users/name/AppData/Local/Temp/RtmpQLnSjE/Rbuild244434d45c05/pkg/vignettes': 'my-vignette.R', 'my-vignette.Rmd'
Execution halted
Error: Command failed (1)
In addition: Warning message:
`cleanup` is deprecated
Execution halted
Exited with status 1.
One first thing, where something might got wrong is that there is no folder called RtmpQLnSjE in my C:/Users/name/AppData/Local/Temp/ directory. Running my Rmd file by hand, does not generate any errors.
I update RStudio to the latest version 1.1.423 and this is my SessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MCMCglmm_2.25 ape_5.0 coda_0.19-1 lme4_1.1-15 Rcpp_0.12.15 Matrix_1.2-12 hmi_0.9.4
loaded via a namespace (and not attached):
[1] lattice_0.20-35 corpcor_1.6.9 digest_0.6.15 withr_2.1.1 MASS_7.3-48 grid_3.4.3
[7] nlme_3.1-131 cubature_1.3-11 minqa_1.2.4 nloptr_1.0.4 devtools_1.13.4 splines_3.4.3
[13] tools_3.4.3 yaml_2.1.16 parallel_3.4.3 compiler_3.4.3 memoise_1.1.0 tensorA_0.36
Concluding as an answer:
Failed to locate the 'weave' output file
This error can have several root causes and is not always easy to trace down. However, there is a good chance that it is related to code inside the vignette, in particular code navigating directories and such (e.g. setwd() or other functions that may rely on relative paths that could differ between a stand-alone run and the more involved R CMD check)
I recently ran across this when a vignette file had a space in the name (like "My Vignette.Rmd"). It was creating an html file called My-Vignette.html. I think it's the hyphen in the name that was causing issues (based on the answer above along with what I'm seeing.)

R Rmetrics packages

I ´ve tried to install some packages from Rmetrics, but it looks I am doing something wrong.
For
https://r-forge.r-project.org/scm/viewvc.php/pkg/fPortfolioBacktest/?logsort=cvs&root=rmetrics&pathrev=4948
I simply used
install.packages("fPortfolioBacktest", repos="http://R-Forge.R-project.org")
but
> install.packages("fPortfolioBacktest", repos="http://R-Forge.R-project.org")
Warning: unable to access index for repository http://R-Forge.R-project.org/bin/windows/contrib/2.12
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘fPortfolioBacktest’ is not available
Exactly the same problem is with
https://r-forge.r-project.org/scm/viewvc.php/pkg/Rsocp/?root=rmetrics&pathrev=3690
> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=Slovak_Slovakia.1250 LC_CTYPE=Slovak_Slovakia.1250 LC_MONETARY=Slovak_Slovakia.1250 LC_NUMERIC=C
[5] LC_TIME=Slovak_Slovakia.1250
attached base packages:
[1] splines stats graphics grDevices utils datasets methods base
other attached packages:
[1] corpcor_1.5.7 fPortfolio_2130.80 fAssets_2100.78 fCopulae_2110.78 sn_0.4-16
[6] mnormt_1.4-3 robustbase_0.7-0 xlsx_0.3.0 xlsxjars_0.3.0 rJava_0.8-8
[11] ttrTests_1.5 PerformanceAnalytics_1.0.3.2 fTrading_2110.77 fBasics_2110.80 timeSeries_2130.90
[16] timeDate_2130.91 dynlm_0.3-0 car_2.0-8 survival_2.36-3 nnet_7.3-1
[21] MASS_7.3-8 lmtest_0.9-27 tseries_0.10-24 quadprog_1.5-3 quantmod_0.3-15
[26] TTR_0.20-2 xts_0.8-0 zoo_1.6-4 Defaults_1.1-1
loaded via a namespace (and not attached):
[1] grid_2.12.0 lattice_0.19-13 Rglpk_0.3-5 slam_0.1-22 strucchange_1.4-2 tools_2.12.0
Is there a fast way how to install them with all the dependencies? I am using Windows XP
Thanks,
Alex
Thanks for adding the error and your sessionInfo.
As I said in my comment, you're running an old version of R (2.12.0). R-forge only builds binaries for the most recent major revision (2.13.X). You need to either upgrade R or build from source. To build from source on Windows, you will need the Windows toolset.

Resources