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.
Related
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.
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]
}
I'm trying to run NetLogo 5.3.1 on R 3.3.1 through rStudio 0.99.903 on my mac 10.10.6. I've also installed Java 1.8.0_77-b03
> system("java -version")
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
> .jinit()
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.8.0_77-b03"
>
> Sys.getenv('JAVA_HOME')
[1] ""
> Sys.getenv('LD_LIBRARY_PATH')
[1] ":#JAVA_LD#"
I'm also running RNetLogo_1.0-2 y rJava_0.9-9.
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RNetLogo_1.0-2 igraph_1.0.1 rJava_0.9-9
loaded via a namespace (and not attached):
[1] magrittr_1.5 rsconnect_0.5 tools_3.3.1
The error I get when I trie to lunch netlogo is as follows.
> nl.path <- ("/Applications/NetLogo 5.3.1/Java")
> ### Start NetLogo
> NLStart(nl.path)
java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
at java.awt.Window.<init>(Window.java:536)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1758)
at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1833)
at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)
at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)
at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
at nlcon.NLink.<init>(NLink.java:109)
I've tried several solutions that I've found here at StackExchange or here and there.
http://conjugateprior.org/2014/12/r-java8-osx/
http://charlotte-ngs.github.io/2016/01/MacOsXrJavaProblem.html
https://github.com/snowflakedb/dplyr-snowflakedb/wiki/Configuring-R-rJava-RJDBC-on-Mac-OS-X
http://stackoverflow.com/questions/35179151/cannot-load-r-xlsx-package-on-mac-os-10-11
http://stackoverflow.com/questions/14915898/rnetlogo-function-nlstart-fails-to-launch-gui
None of them have worked on my computer ...
does anyone have any idea what should I have to do to make this work?
Thanks!
PS1/ I have the same exact results running R from the mac shell.
PS2/ I've installed java 1.6 and after test the issue and see that doesn't make any change I deleted it.
As someone commented (I really don't know why they didn't post the answer) the key to the problem was I was using the wrong package to start NetLogo.
First of all one have to be sure that R has the correct Java Home set. So run this on mac shell.
R CMD javareconf
Then, on R shell / console we have to install the rJava in source way to compile with our Java location and version.
install.packages("rJava", type="source", repos="http://cran.us.r-project.org”)
Then we have to install JGR
install.packages("JGR")
and run and open the JGR console.
require(JGR)
### Start JGR
JGR()
Form there on... we run the rest of the script / commands on the JGR console.
### call netlogo. Set the path where NetLogo is installed
nl.path <- ("/Applications/NetLogo 5.3.1/") # Mac path
### Start NetLogo
# The /Java directory is where the NetLogo java app lives. Don't set
# completely before to make the models path work
NLStart(file.path(nl.path, "Java"))
It should work.
PS/ As you can read here, this functions isn't supported on NetLogo for mac and linux
I am getting the error message below when I try to compile any code. Below is an example and the output from sessionInfo(). The example used to work but I had problems with RcppArmadillo. So I installed the for HPC version of the gfortran compiler, which was a mistake. R just crashed when I tried to compile something (CRAN also warns about the HPC version). In the end, I installed the version on CRAN here but now any call to cppFunction or sourceCpp produces the error below. I have already tried to uninstall gfortran, R, Rcpp and install them again. Same error. The output from gfortran -v is a little confusing. Any ideas?
Example code
require("Rcpp")
cppFunction('
int add(int x, int y, int z) {
int sum = x + y + z;
return sum;
}'
)
Error message
Error in dyn.load(context$dynlibPath) :
unable to load shared object '/var/folders/cc/_mskgpdd6f77hrg4rsp4zq1h0000gq/T//RtmpHRb5JV/sourcecpp_24fb5226c6fc/sourceCpp_96369.so':
dlopen(/var/folders/cc/_mskgpdd6f77hrg4rsp4zq1h0000gq/T//RtmpHRb5JV/sourcecpp_24fb5226c6fc/sourceCpp_96369.so, 6): Symbol not found: ___emutls_get_address
Referenced from: /usr/local/lib/libstdc++.6.dylib
Expected in: /usr/local/lib/libgcc_s.1.dylib
in /usr/local/lib/libstdc++.6.dylib
Output from session info
R version 2.15.2 (2012-10-26)
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] Rcpp_0.10.1 boot_1.3-7 xtable_1.7-0 stringr_0.6.1
[5] mi_0.09-18 arm_1.5-08 abind_1.4-0 R2WinBUGS_2.1-18
[9] coda_0.14-7 lme4_0.999999-0 Matrix_1.0-9 lattice_0.20-10
[13] car_2.0-15 nnet_7.3-5 MASS_7.3-22 plyr_1.7.1
[17] foreign_0.8-51
loaded via a namespace (and not attached):
[1] grid_2.15.2 nlme_3.1-105 stats4_2.15.2 tools_2.15.2
versions of compiler
> gcc -v
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
> gfortran -v
Using built-in specs.
Target: i686-apple-darwin8
Configured with: /Builds/unix/gcc/gcc-4.2/configure --prefix=/usr/local --mandir=/share/man --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --build=i686-apple-darwin8 --host=i686-apple-darwin8 --target=i686-apple-darwin8 --enable-languages=fortran
Thread model: posix
gcc version 4.2.3
Somehow I ended up with a version of libstdc++.6.dylib in /usr/local/lib. This version is picked up when I compile certain code with Rcpp or inline and produces the error. It seems to overwrite the the system version in /usr/lib. For now, I just renamed /usr/local/lib/libstdc++.6.dylib to .../libstdc++.6-SAVE. I am not sure whether that will create other problems but Rcpp is running again and the ?cfunction examples also work!
EDIT: It's actually still screwed up. Here are the steps to solve the problem for the current R session. 1) start R with /usr/local/lib/libstdc++.6.dylib unchanged, 2) rename /usr/local/lib/libstdc++.6.dylib, 3) happily use Rcpp. When I now restart R, however, I still get the old error message. I have to go through the three steps again to make it work in the current R session.
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