check.Renviron being ignored (OSX + R 2.15) - r

The semester has ended and I'm now bringing some packages up to R 2.15 (I did not want to change them while students were using them). So I'm doing my usual thing, which worked under R 2.14. As far as I can see, the documentation has not changed with respect to any of this, but I may have missed it.
I have edited my package ChemoSpec but when I go to check it, R gives an error about packages required but not available, then lists them. These packages are available, they are in a local directory which is pointed a-:
.libPaths()
[1] "/Users/bryanhanson/R_pkgs"
[2] "/Library/Frameworks/R.framework/Versions/2.15/Resources/library"
The allegedly missing packages are in fact in /Users/bryanhanson/R_pkgs.
I am aware my .Rprofile is skipped by the checking process, so the .libPaths are not being set by .Rprofile Instead, I have a check.Renviron file which is located in /Users/bryanhanson/.R and contains the following lines:
# Bryan's check.Renviron for customizing check environment
# resides in /Users/bryanhanson/.R
R_LIBS = /Users/bryanhanson/R_pkgs
I have tried to check with the following commands in the terminal
R --as-cran CMD check ChemoSpec
R --vanilla CMD check ChemoSpec
The response to each of these is slightly different, but both fail because of not finding the dependencies, because, apparently, R is not looking in /Users/bryanhanson/R_pkgs even though I think I have told it do so.
Any suggestions? It must be something simple.
Here is the sessionInfo():
sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] sos_1.3-1 brew_1.0-6

Related

circular dependency error in R package check, yet no circular refs in Depends

I am getting a circular dependency error for my R package when running CHECK:
checking package dependencies ... ERROR
There is circular dependency in the installation order:
One or more packages in
then a long list of packages.
However, my Depends category in DESCRIPTION is very minimal:
Depends: methods, R (>= 3.5.0), magrittr
And all other referenced packages are in either Imports or Suggests. One package I have in Imports also lists my package in their Imports, but I did not think that would lead to a dependency issue. I don't think any of the other packages I have in DESCRIPTION list mine in theirs.
I've searched quite a bit online but found no relevant solutions. Any ideas? Thanks in advance for the advice.
Session info:
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5 tinytex_0.31 xfun_0.28
Depends and imports both require a dependency. The main difference is that imports doesn't add items to the user's search path. See here or here. You can't list a package under your "imports" that lists you under their "imports" -- that part is the same as "depends." Packages use functions from packages all the time, but the sharing is just one-way.
One possible work-around is copying the function (with permission from the other package author) into your own package.
Another option that I've seen used by other packages is to move shared logic to a separate helper package and then both packages can Import that helper package.
Finally, if it's a function you don't really need you can move it to suggests and then check if that package is installed only when you need the function and can throw an error if not.

Change of location of R libraries throws error

I have an issue with the library path of R. Maybe the answer is out there already, but I was not able to find it. I am using R together with RStudio Version 1.1.456. All my additional libraries used to be in a directory dir1 <- \\SHARE\TOOLS_OLD$\R-3.5.1 which I append with .libPaths(dir1). In this setup, everything works as expected.
The problem occured after I copied all the libraries in directory \\SHARE\TOOLS_OLD$\R-3.5.1 to a new location \\NAS\TOOLSNEW$\R-3.5.1. I did not update the R version and I want to keep all the package versions the same such that I have exactly the same setup as before. That is why I did not reinstall the packages in the new location.
When I open a new R session and run the three lines of code
dir2 <- \\NAS\TOOLSNEW$\R-3.5.1
.libPaths(dir2)
.libPaths()
I get the correct output of .libPaths()
[1] "\\\\NAS/TOOLSNEW$/R-3.5.1" "C:/Apps/R-3.5.1/library"
but R also throws an error:
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Apparently some packages remember the original location where they were installed. Is there a way to copy packages to a new location without reinstalling them? If that is not possible, is there an easy (i.e. non-manual) way to reinstall my package tree without upgrading any of the packages (including the dependencies) i.e. defining the version of each package?
Thanks for your help!
PS: Here is my session info, just in case.
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252
LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C
[5] LC_TIME=German_Switzerland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1 yaml_2.2.0
The problem can have many causes, e.g. there might be some dependencies which are lost by copying the package folder or that the registry entries don't match anymore, but I'm guessing here. When you copy packages from older versions you have to run update.packages (but this might update any package to the currently available version, which you don't want). Check out the R-FAQ and this Stackoverflow question.
You can install packages of a certain version with the devtools package.
install.packages("devtools")
require(devtools)
install_version(somePackage, version = neededVersion)
How I did it was I created a data.frame of all the required packages with the corresponding version number, like
> requiredPkgs
Package Version
condformat "condformat" "0.9.0"
DT "DT" "0.17"
formattable "formattable" "0.2.1"
ggplot2 "ggplot2" "3.3.3"
ggthemes "ggthemes" "4.2.4"
htmlTable "htmlTable" "2.1.0"
and then installed them in a loop
for(iPkg in requiredPkgs) {
install_version(iPkg[1], version = iPkg[2]
}

Disable 'Crippled Lapack' warning in RcppArmadillo

I'm using RcppArmadillo to solve a linear system. The R binary for Macs from CRAN is configured to use a built-in subset of BLAS and Lapack, and I have not been successful in building R to use an external BLAS + Lapack (I sent an email to r-sig-mac for help, but so far haven't received any answer).
Unfortunately, in addition to a possible lack in performance, every time I run the code I'm greeted with a low-level warning,
warning: solve(): refinement and/or equilibration not done due to crippled LAPACK
which quickly fills my terminal console (I'm running this in a loop). How can I configure RcppArmadillo to not issue this warning?
sessionInfo()
R version 3.3.0 Patched (2016-06-05 r70718)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.4 (El Capitan)
locale:
[1] en_NZ.UTF-8/en_NZ.UTF-8/en_NZ.UTF-8/C/en_NZ.UTF-8/en_NZ.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RcppArmadillo_0.7.200.1.0
loaded via a namespace (and not attached):
[1] tools_3.3.0 Rcpp_0.12.5
Look at configure when you install it; check the test output. The code (minus some comments) essentially is:
## external LAPACK has the required function
lapack=$(${R_HOME}/bin/R CMD config LAPACK_LIBS)
hasRlapack=$(echo ${lapack} | grep lRlapack)
if [ "${hasRlapack}" == "" ]; then
## We are using a full Lapack and can use zgesdd -- so #undef remains
echo "system LAPACK found"
cp inst/include/RcppArmadilloLapack.h.in inst/include/RcppArmadilloLapack.h
else
## We are using a R's subset of Lapack and CANNOT use zgesdd etc, so we mark it
echo "R-supplied partial LAPACK found"
echo "* some operations may not be available"
sed -e 's/\/\/ \#undef ARMA_CRIPPLED_LAPACK/\#define ARMA_CRIPPLED_LAPACK 1/' \
inst/include/RcppArmadilloLapack.h.in > inst/include/RcppArmadilloLapack.h
fi
So in a nutshell you have two options:
i) have a real external LAPACK or
ii) use an R version that has a non-crippled LAPACK bundled -- ie R 3.3.0.
Edit on 12-Mar-2016: So there was a bug in that R 3.3.0 was not recognized properly in the case of not having a system LAPACK -- ie OS X as poor Windoze is handled differently anyway. This is now taken care of in the GH repo. Thanks to #baptiste for spotting it.

Error trying to generate notes with reports package on R

I am trying to generate notes for the reports package https://github.com/trinker/reports/ , and followed the steps from the youtube video http://goo.gl/x9ulf0 . I did run the chunk Tyler has there http://goo.gl/XHouuc but when I try to generate the notes i keep getting the following error message:
> notes()
Error in value[[3L]](cond) :
Possible causes:
1) The main file directory is not set as the working directory
2) ~/ARTICLES/notes.xlsx or ~/ARTICLES/notes.csv does not exist
I then tried to set my working directory to different places and even to move the ARTICLES directory to my home ~ directory, but i keep getting the exact same message no matter where i place the wd. i read the source code for the notes function but couldn't figure out where the problem might be. the notes2 function also gives me the same error
here is my sessioninfo:
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitcitations_0.4-7 bibtex_0.3-6 knitr_1.4.1 slidifyLibraries_0.3
[5] slidify_0.3.52 reports_0.2.0
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.7 formatR_0.9 httr_0.2 markdown_0.6.3
[6] RCurl_1.95-4.1 rJava_0.9-4 stringr_0.6.2 tools_3.0.1 whisker_0.3-2
[11] xlsx_0.5.1 xlsxjars_0.5.0 XML_3.95-0.2 xtable_1.7-1 yaml_2.1.8
any thoughts on what the problem might be?
#Ricardo Pietrobon Thank you for bringing this to my attention.
Ok the problem is that the xlsx package relies on Depends and not Imports to load the call to .jnew from the rJava package. This means if you have used library(xlsx) then read.xlsx works fine, however if only the read.xlsx is attached via namespace then rJava's .jnew is not called. hence the error. This is confirmed in that the NAMESPAE file for xlsx contains:
import("xlsxjars")
exportPattern("^[^\\.]")
This became a problem because CRAN recently required more restrictive checks and I started using importFrom rather than import and relying on Depends. I actually recieved a warning along these lines from Prof. Brian Ripley about relying on Depends. At the time I didn't understand it but heeded it. I now get exactly what he was talking about.
For the time being I have added rJava to the Depends field in the DESCRIPTION file. This throws a NOTE in the CRAN check as I'm Depending but not importing and needs to be removed after xlsx is updated.
I opened an issue with the xlsx package in the link below regarding the problem. Hopefully this gets fixed and uploaded soon. In the mean time notes() should be operating fine.
https://code.google.com/p/rexcel/issues/detail?id=24&thanks=24&ts=1379267751
I opened an issue at report's GitHub concerning this and as I believe the original problem has been solved, further conversation can be directed there.

loading Rcpp through JGR Console

I have created a package that depends on Rcpp and RcppArmadillo. My package operates smoothly without a problem on the R console. However, when I try to loaded it from JGR console it reports the following error
Error: package 'Rcpp' 0.9.9 is loaded, but >= 0.9.10 is required by 'RcppArmadillo'
Actually, I have updated Rcpp to version 0.9.10 on my machine. In the R console you can see that
sessionInfo()
attached base packages:
[1] compiler stats graphics grDevices utils datasets methods base
other attached packages:
[1] prophecy_2.1 XLConnect_0.1-9 XLConnectJars_0.1-4 rJava_0.9-3 RcppArmadillo_0.2.36 Rcpp_0.9.10
I appreciate the help.
This has nothing to do with Rcpp and is all about your R patch:
Print the result of .libPaths()
Look at the result of library()
Do that both on the console and with JGR. You probably have different outcomes.
Delete the old Rcpp 0.9.9 in the path added by JGR.

Resources