require(RQuantLib) fails - r

I am trying to load RQuantLib but I get the following error:
> require(RQuantLib)
Loading required package: RQuantLib
Error : .onLoad failed in loadNamespace() for 'RQuantLib', details:
call: if (is.character(qc) && nchar(qc) > 1) {
error: missing value where TRUE/FALSE needed
In addition: Warning message:
running command 'bash -c 'type -p quantlib-config' 2>/dev/null' had status 1
I am pretty new to programming in general so I am not sure what this means. I am working in an Mac OS Maverick environment, I downloaded the latest version of RQuantLib (0.3.12) and the "R Package Installer" says it is installed. (I installed RQuantLib from the terminal using "R CMD INSTALL RQuantLib" as using install.packages() from within R did not work - it gave me an error saying QuantLib was not configured, although it was running fine in from the terminal.) I am running R from the R console. QuantLib works fine and so does Rcpp.
I checked the "NAMESPACE" document in the RQuantLib folder and it says:
import(methods)
importFrom(Rcpp, Rcpp.plugin.maker)
useDynLib(RQuantLib)
exportPattern("*.default")
export(
##--arrays.R
"oldEuropeanOptionArrays",
"EuropeanOptionArrays",
"plotOptionSurface",
##--asian.R
"AsianOption",
##--bermudan.R
"BermudanSwaption",
"summary.G2Analytic",
"summary.HWAnalytic",
"summary.HWTree",
"summary.BKTree",
##--bond.R
"ZeroCouponBond",
"ZeroPriceByYield",
"ZeroYield",
"FixedRateBond",
"FixedRateBondYield",
"FixedRateBondPriceByYield",
"FloatingRateBond",
"ConvertibleZeroCouponBond",
"ConvertibleFixedCouponBond",
"ConvertibleFloatingCouponBond",
"CallableBond",
"FittedBondCurve",
##--calendars.R
"isBusinessDay", "businessDay",
"isHoliday",
"isWeekend",
"isEndOfMonth",
"getEndOfMonth", "endOfMonth",
"adjust",
"advance",
"businessDaysBetween",
"getHolidayList", "holidayList",
"setCalendarContext",
##--dayCounter.R
"dayCount",
"yearFraction",
"setEvaluationDate",
##--discount.R
"DiscountCurve",
"plot.DiscountCurve",
##--implied.R
"EuropeanOptionImpliedVolatility",
"AmericanOptionImpliedVolatility",
"BinaryOptionImpliedVolatility",
##--option.R
"EuropeanOption",
"AmericanOption",
"AmericanOption.default",
"BinaryOption",
"BarrierOption"
)
S3method("plot", "Option")
S3method("print", "Option")
S3method("summary", "Option")
S3method("plot", "Bond")
S3method("print", "Bond")
S3method("summary", "Bond")
If I try to specify the path where the Terminal wrote that it installed RQuantLib while requiring it I get the following error:
> require('RQuantLib', lib.loc = "C:/Users/dealmer/Library/R/3.1/library/RQuantLib/libs")
Loading required package: RQuantLib
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
no library trees found in 'lib.loc'
So, do I need to move something from there to where the other R libraries are? (There is already a folder named "RQuantLib" in the folder where the other R library folders are, that's where I found the NAMESPACE doc for example) The path that the Terminal gave me I can't follow in the Finder window however because it doesn't show the "Library" folder and I don't know how to make it do that.)
This is what .libPaths() gives me:
> .libPaths()
[1] "/Users/dealmer/Library/R/3.1/library"
[2] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library"
The R libraries are in [2].
I've tried googling but I can't find anything that seems helpful. Any help will be very appreciated. Thank you
- Dom

I think the issue is that on Linux we have quantlib-config in the $PATH:
edd#max:~$ quantlib-config --help
Usage: quantlib-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] \
[--libs] [--cflags]
edd#max:~$ quantlib-config --version
1.4
edd#max:~$
I don't own an OS X box, so I depend on someone like you help with a better configure setup. It should just work if you copy (or soft-link) quantlib-config into your path (eg /usr/local/bin), or adjust $PATH otherwise to include the directory it is in.

I had the same issue and after some hours of struggle I manage to use something not very rigorous but it works!
It seems that R has some issues evaluating system("bash -c 'type -p quantlib-config'").
After having installed QuantLib, typing the command bash -c 'type -p quantlib-config' in Terminal gives us the path of our quantlib-config which is for me /opt/local/bin/quantlib-config.
So I went back to my source folder for RQuantLib (version 0.4.0) and replaced qc in file R/inline.Rby:
qc <- as.character("/opt/local/bin/quantlib-config")
and rebuilt the package using the terminal command R CMD install RQuantLib/.
As I said, not very sexy but it works.
A restart of R and Rstudio is necessary.
Hope it helps!

Related

Rscript is not recognising libraries when using renv

I am working on Mac OSX, using v3.6.3 of R and using renv. In Rstudio and R, I can load the libraries of my installed packages, e.g library(ggplot2) works. However when I run a script using Rscript I get the message
Error in library(ggplot2) : there is no package called ‘ggplot2’
According to this SO answer, I need to make sure that the value of
Sys.getenv('R_LIBS_USER') in R.exe
is the same as the value of
Rscript.exe -e ".libPaths()"
But the value is the same, both are pointing to the renv-system-library in my project folder.
So how do I fix this?
It may be better to specify the lib.loc in library call
library(ggplot2, lib.loc = '/path/where/library/is/located')
I managed to solve this. akruns answer was useful, it did not work, but pointed me incorrect direction. The answer did not work because using it, I received the following error:
Error: package or namespace load failed for ‘ggplot2’:
.onLoad failed in loadNamespace() for 'pillar', details:
call: utils::packageVersion("vctrs")
error: there is no package called ‘vctrs’
Now vctrs was in the '/path/where/library/is/located' so I think dependent packages were not being loaded from that path but the default for Rscript. Putting a print(.libPaths() in the script gave
"/usr/local/Cellar/r/3.6.3_1/lib/R/library"
instead of
[1] "/Users/Chris/Sites/app_name/renv/library/R-3.6/x86_64-apple-darwin18.7.0"
[2] "/private/var/folders/5_/p_yl0439059b7_jdqzrm0hr40000gr/T/RtmptdHcWN/renv-system-library"
for .libPaths() in Rstudio. Looking at the ruby program that was actually running the Rscript program, I found it was being run with the --vanilla option, i.e
Rscript --vanilla script_name
Removing the --vanilla option fixed the problem. I think that scripts with the --vanilla option stopped working because I reinsalled R using brew to fix another problem I was having and as part of this issued this command:
brew link --overwrite r

Trouble loading rJava into R and RStudio [duplicate]

I recently "upgraded" from OSX Mountain Lion to Yosemite and from R 3.1.3 to 3.2. Immediately after the upgrade, when I opened R or RStudio I got a pop-up message saying that I needed to install Java 6. In addition, loading rJava or any package that depends on rJava (e.g., xlsx) caused RStudio to crash (R also crashed when I tried this by opening R.app directly).
After trying a few fixes found on Stack Overflow and elsewhere (more details below), I am at a point where loading rJava or any package that depends on rJava no longer causes R to crash, but results in the following error:
library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so
Reason: image not found
Error: package or namespace load failed for ‘rJava’
However, if I invoke R from the command line and then load rJava or any package that depends on rJava, it seems to work (or at least I don't get any error messages).
I've tried a number of different attempted fixes, some of them a few times, and can't quite remember exactly what I did in what order (didn't realize this would be such a morass and wasn't really keeping track), but here's the gist of it:
Added the following to my .bash_profile (per this SO answer):
export JAVA_HOME="/usr/libexec/java_home -v 1.8"
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/server
Reconfigured java from the command line as follows:
sudo R CMD javareconf -n
Checked options("java.home") and discovered this was set to NULL. I tried setting it to the following (per this SO question):
options("java.home"="/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre")
Installed the latest Java Development Kit and reinstalled rJava from source (can't remember where I found that one).
At some point while trying all of these, I was able to load rJava without crashing R, but instead got the error message posted above. In addition, when I quit RStudio, it would seem to close normally, but then an "RStudio quit unexpectedly" message would pop up, indicating that the program had crashed while trying to close.
I finally decided to install Java for OS X 2014-001 (Java 6), as I seemed to be running out of options. Now, when I opened R or RStudio the "This software needs Java 6" pop-up message no longer appeared. However, I was still getting the .onLoad failed in loadNamespace() for 'rJava' error message posted above.
In reviewing some of the posts I'd already looked at, I noticed another SO answer that I'd missed before, which recommended opening RStudio with the following command line code that gives RStudio the correct path to java:
LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio
That opened an RStudio window and I was also able to load rJava and packages that depend on it without getting an error.
Lastly, I tried running R from the command line (which I hadn't done before). It turns out that on the command line, loading rJava or any package that depends on rJava works and does not throw any errors.
So, I can now get rJava to work if I open RStudio from the command line with the code that gives RStudio the java path (as noted above). However, I'd like to find a way to fix the underlying problem, whatever it may be, so that RStudio can be opened in the usual Mac way, without needing a command line kludge. I'm also concerned that having an old version of Java installed could cause problems down the road.
Does anyone have any ideas about how to diagnose and solve this issue?
I had the same problem and went through the same steps as you. The final step to allow starting RStudio through Finder/Spotlight was to link libjvm.dylib to /usr/local/lib:
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
-f flag is added to force overwriting existing file/link
On OSX El Capitan 10.11, the user doesn't have permission to write to /usr/lib. So instead, use the following command:
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
You can load the libjvm.dylib explictly, by run like
dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
library(rJava)
On macOS High Sierra (10.13.1) and Java Version 9 you have to use a slightly different JVM path (notice the missing jre folder in the path compared to the instructions for earlier Java versions):
sudo ln -f -s $(/usr/libexec/java_home)/lib/server/libjvm.dylib /usr/local/lib
You also have to notify R about the JVM:
MY_R_VERSION=$(Rscript -e "cat(with(R.version, sprintf('%s.%s', major, substring(minor, 1, 1))))")
ln -s /usr/local/lib/libjvm.dylib /Library/Frameworks/R.framework/Versions/$MY_R_VERSION/Resources/lib/
Following command works:
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
After that, in RStudio, loading rJava works through loading of the "xlsx" package.
library("xlsx")
P.S. #1 Environment: Mac OS X El Capitan 10.11.3+ with RStudio 0.99.491+ and R 3.2.3+. (I've now tested this also on macOS Sierra (10.12) and R.3.3.1.)
P.S. #2 I find that openxlsx is much faster and doesn't rely on Java to work, so I'm now using that package. Hope that helps others.
You should be able to use the CRAN rJava, without needing to recompile rJava or do any additional steps by linking the shared library to the R frameworks library directory.
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /Library/Frameworks/R.framework/Libraries
This is how I configured it working properly on two Macs running Mac OS X El Capitan (10.11.6):
Uninstall 'rJava' by issuing the following commands in a terminal window:
Rscript -e 'remove.packages("rJava")'
sudo Rscript -e 'remove.packages("rJava")'
Download and install the Java software from Oracle: https://www.java.com/en/download/mac_download.jsp
Add the following lines to /Users/<userid>/.bashrc using your favorite editor:
# Set JAVA_HOME so rJava package can find it
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)/jre
Close and restart any terminal, R, and RStudio windows (to pick up the changes to .bashrc).
Run the following command in a Terminal window:
sudo ln -sf $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
Run the following command in a Terminal window:
sudo Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
Here is the easy steps for it:
remove the rJava package: remove.packages(rJava)
close R
install latest Java on you mac
open terminal and type this command: sudo R CMD javareconf
Open R and install rJava with this command:
install.packages("rJava", dependencies=TRUE, type="source")
The image not found issue exists with a brand-new install on OSX High Sierra with the latest Java SE 10 JDK.
I was able to solve the path issue with rJava using the fix found on the rJava Github issues page: https://github.com/s-u/rJava/issues/78
R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
Here what worked for me on MAC:
in your ~/.profile or ~/.bashrc add this line:
%export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home
1.1 % source .profile (or % source .bashrc)
% sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
remove.packages(rJava)
remove.packages(Rweka)
From the terminal enter this command:
%sudo R CMD javareconf
install.packages("rJava", dependencies = TRUE, type = "source")
install.packages("rJava", dependencies = TRUE, type = "source")
Load your library("rJava", "RWeka")
Best of luck.
Maybe another simple answer which does not touch your filesystem:
$ install_name_tool -add_rpath /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
(Substitute jdk1.8.0_131.jdk with your JDK path.)
Check the location of libjvm.dylib file.
Try this, in my case this worked:
dyn.load('/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/lib/server/libjvm.dylib')
library(rJava)
I went through all the troubleshooting I could find, then installed jdk-11.0.1_osx-x64_bin.dmg from: Oracle downloads
Everything worked perfectly after that.
Check the version of the library that was not loaded when you run library('rJava') and match it to the java version you need installed.
I noticed that 'rJava' is pretty strict about JDK version while loading in Rstudio. In my case (Mac OS. 10.14.6 - Mojave) I had installed jdk-13 which was tested against jdk-11.
I have linked my JDK version to a non-existent directory that was assumed to be valid by Rstudio (JDK 11):
sudo ln -sf /Library/Java/JavaVirtualMachines/jdk-13.jdk/ /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk
and suprisingly it works like a charm...
BTW., there was no problem to run 'rJava' following the previous instructions in native R.
Here you can download the legacy Java version 6 for El Capitan: https://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US
After doing so, the rJava package works for me.
This line below has solved the same problem I was having with rJava package as some others in this discussion did. I'm sure there are more than one solution to this problem and I sincerely thank them all for their contributions because sometimes one line like the one below saves a lot of time from going to trash!
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
Run the following on the command line: sudo R CMD javareconf
Several solutions above have mentioned this, but they also suggest that one remove and subsequently re-install the rJava package. I found those additional steps to be unnecessary.
You can change the reference in R by using the following command:
sudo install_name_tool -change /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server/libjvm.dylib /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so

Getting gputools and gmatrix in R to run smoothly on Linux

I am having trouble getting R to recognize gmatrix for R, running through Rstudio. My details are below.
Things that are accomplished and DONE:
install of openSuse Tumbleweed x86_64
install of NVIDIA graphics driver 361.42
install of CUDA 7.5 & symbolic link for /usr/local/cuda
set LD_LIBRARY_PATH & PATH
R 3.2.5
RStudio 0.98.501-1.62
patched /usr/local/cuda/include/host_config.h, line: 115 by increasing the "4"'s to "5"'s (this pertains to the gcc compiler)
install package gputools
~ partial install of package gmatrix
*I had to edit the host_config.h file because cuda is not supported for the gcc compiler that Tumbleweed ships with. I basically broke the evaluation that checks for version and set it to 5.9 instead of 4.9. Was this a supremely naive thing to do?
Things not Done, help required:
-I wasn't able to install gmatrix properly. I got R to install by manually adding the LD & PATH directories using the Sys.setenv()
> Sys.setenv("LD_LIBRARY_PATH"="/usr/lib64/R/lib:/lib:/usr/local/lib64:/usr/local/cuda/lib64")
> Sys.setenv("PATH"="/home/eamergent/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/cuda/bin")
However, I am unable to load the gmatrix package, yet gputools works fine:
> library(gputools) "no issues"
> library(gmatrix)
> Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/home/eamergent/R/x86_64-suse-linux-gnu-library/3.2/gmatrix/libs/gmatrix.so':libcudart.so.7.5: cannot open shared object file: No such file or directory Error: package or namespace load failed for ‘gmatrix’
*The Error makes it seem that libcudart.so.7.5 is to blame
However,
/usr/local/cuda/lib64/libcudart.so.7.5 does in fact exist:
> eamergent#linux-pnx7: ls /usr/local/cuda/lib64/libcuda
libcudadevrt.a libcudart.so libcudart.so.7.5 libcudart.so.7.5.18 libcudart_static.a
*I used tab to get a shorter list. there are many more in lib64
Any ideas on how to get R to recognize the already installed gmatrix package? Or how to properly reinstall without using the R environment path fix that I used above?
I had the same issue on Ubuntu 14.04 where the system and R (Sys.setenv()) shared library paths were set properly, but R failed to load the CUDA shared library. What worked was to set the CUDA shared library path using ldconfig.
as root or prefix commands with sudo:
# echo "/usr/local/cuda/lib64/libcuda" > /etc/ld.so.conf.d/cuda.conf
# ldconfig
then
# R
> install.packages("gmatrix")
or if gmatrix is already installed
# R
> library(gmatrix)
> gtest()

Error installing and running rcpp

I'm pretty new to R so apologies for a stupid question. I'm trying to get rcpp running but I'm stuck in an endless loop of R asking me to re-install RTools.
I broadly followed the code in this blog post, although first time off I installed everything by hand & I've subsequently re-installed everything a few times over. I'm running Windows 7, R version 3.1.2, R Studio Version 0.98.1091 (not that this should matter much) and RTools 3.1.
An edited highlight of what my console looks like is as follows:
> library(installr)
Welcome to installr version 0.15.3...
> install.Rtools()
Loading required package: devtools
No need to install Rtools - You've got the relevant version of Rtools installed
> find_rtools()
[1] TRUE
> library(Rcpp)
> evalCpp("1+1")
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 65535 occurred building shared library.
At which point a dialog box pops up saying:
Install Build Tools
Compiling C/C++ code for R requires installation of additional build tools.
Do you want to install the additional tools now?
And then I get directed to download and re-install RTools 3.1 from cran all over again.
I've seen that this can be an issue with the PATH variable but I've tried various things including:
Nothing (extra) in the PATH variable
Including both references to R (C:\Program Files\R\R-3.1.2\bin\x64) and RTools (C:\RBuildTools\3.1\bin;C:\RBuildTools\3.1\gcc-4.6.3\bin;) in the PATH. Once with RTools first, once with R first
Including just a reference to RTools in the PATH as the initial install file directed me to do.
Any ideas on things to try would be gratefully accepted!
EDIT
Following Dirk's comment it looks like I might have a problem with how RTools is installed. I've followed the instructions from several blogs / tutorials on how to install RTools; all to no avail (yet!)
This GitHub page gives some instructions on how install and check that the installation has worked. I've followed all the checks (see below for copy of the console) and it looks like I have a working install of RTools, but when I try to run evalCPP() again I get the same error as before directing me to install RTools.
> Sys.getenv('PATH')
[1] "C:\\Program Files\\R\\R-3.1.2\\bin\\x64;C:\\RTools\\bin;C:\\RTools\\gcc-4.6.3\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Enterprise Vault\\EVClient\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\VSShell\\Common7\\IDE\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\100\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\PrivateAssemblies\\;C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\;C:\\Program Files\\Microsoft\\Web Platform Installer\\;C:\\Program Files (x86)\\Microsoft SDKs\\TypeScript\\1.0\\;C:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn\\"
Warning message:
printing of extremely long output is truncated
> system('g++ -v')
Using built-in specs.
COLLECT_GCC=C:\RTools\GCC-46~1.3\bin\G__~1.EXE
COLLECT_LTO_WRAPPER=c:/rtools/gcc-46~1.3/bin/../libexec/gcc/i686-w64-mingw32/4.6.3/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /data/gannet/ripley/Sources/mingw-test3/src/gcc/configure --host=i686-w64-mingw32 --build=x86_64-linux-gnu --target=i686-w64-mingw32 --with-sysroot=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --prefix=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/mingw32 --with-gmp=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpfr=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --with-mpc=/data/gannet/ripley/Sources/mingw-test3/mingw32mingw32/prereq_install --disable-shared --enable-static --enable-targets=all --enable-languages=c,c++,fortran --enable-libgomp --enable-sjlj-exceptions --enable-fully-dynamic-string --disable-nls --disable-werror --enable-checking=release --disable-win32-registry --disable-rpath --disable-werror CFLAGS='-O2 -mtune=core2 -fomit-frame-pointer' LDFLAGS=
Thread model: win32
gcc version 4.6.3 20111208 (prerelease) (GCC)
> system('where make')
C:\Rtools\bin\make.exe
I've also had a look at Appendix D of R Installation and Admin. I can't see anything in here I've not already tried except for section D.4 which implies I might need to rebuild rcpp from source using my installed RTools. I don't have time to do this right away but will give it a try unless people say this route is not worth my time.
EDIT v2
So I tried building rcpp from source ... and that didn't work either. I downloaded both the package source and windows binaries from the CRAN Rcpp package page. In the R console I now get:
> install.packages(pkgs = "C:/Rcpp_0.11.4.tar.gz", repos = NULL, contriburl = NULL, type = "source", verbose = TRUE)
Installing package into ‘C:/Users/james.macadie/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
system (cmd0): C:/PROGRA~1/R/R-31~1.2/bin/x64/R CMD INSTALL
Warning in install.packages :
package ‘C:/Rcpp_0.11.4.tar.gz’ is not available (for R version 3.1.2)
I guess my active questions now boil down to:
Reading the whole of the post above can anyone tell me how to fix things so it just works? Or, failing that...
What tests can I run to check I really do have Rtools installed correctly? Everything I have found on the internet suggests I do: system('where make') etc. However, the evidence of being unable to run evalCpp or other rccp functions suggests I don't.
What am I doing wrong when building from source? Should I try the command line option?
EDIT v3
Running evalCpp with showOutput= TRUE and verbose = TRUE I think I've tracked the error back to R CMD SHLIB not working. I followed this blog, which shows how to work with the command line R directly. However when I get to the line R CMD SHLIB sequence_examples.c the execution just skips straight to the next command line without doing anything, generating any files in the directory or throwing any errors. I tried running the --help options at the command line but get the same sort of error:
C:\Users\james.macadie> R --help
Or: R CMD command args
where 'command' is one of:
INSTALL Install add-on packages
REMOVE Remove add-on packages
SHLIB Make a DLL for use with dynload
BATCH Run R in batch mode
build Build add-on packages
check Check add-on packages
Rprof Post process R profiling files
Rdconv Convert Rd format to various other formats
Rdiff difference R output files
Rd2pdf Convert Rd format to PDF
Rd2txt Convert Rd format to pretty text
Stangle Extract S/R code from vignette
Sweave Process vignette documentation
config Obtain configuration information about R
open Open a file via Windows file associations
texify Process a latex file
Use
R CMD command --help
for usage information for each command.
C:\Users\james.macadie> R CMD SHLIB --help
C:\Users\james.macadie>
N.B. for people reading the earlier code samples higher up this post I have changed a few things since those code snapshots:
I've installed R directly into C:\R. It used to be in C:\Program Files\R\ but as has been suggested file paths with spaces in can cause problems
I'm referencing Rtools under C:\Rtools\ and not C:\RBuildTools\
Thanks for any suggestions, as ever
Had the same endless loop issue when trying to install Twitter's BreakoutDetection (which is also written in cpp)
fixed by executing the following
Sys.setenv(PATH="%PATH%;C:/Rtools/gcc-4.6.3/bin;c:/Rtools/bin")
and then answering "no" when presented with the following prompt:
"Install Build Tools Compiling C/C++ code for R requires installation of additional build tools. Do you want to install the additional tools now?"
Didn't try these actions independently so not sure if either on their own would have fixed the issue
I found that ensuring all of these were in my path fixed it. I did this with RStudio closed; I didn't reboot after.
C:\Program Files\R\R-3.1.3\bin\x64
C:\Program Files\R\R-3.1.3\bin
C:\RBuildTools\3.2\bin
C:\RBuildTools\3.2\gcc-4.6.3\bin64
C:\RBuildTools\3.2\gcc-4.6.3\bin
C:\RBuildTools\3.2\gcc-4.6.3\i686-w64-mingw32\bin
These are on my Win7-64bit computer. YMMV, and I'm mostly posting this to ensure others see it if they are having the same issue.
In the end it was something a bit left-field. Inspired by the following post, I had a look at the ComSpec environment variable. Not quite sure how, but I had it set to "cmd.exe".
Removing the double quotes, so it said cmd.exe, and then rebooting fixed everything.
Thanks to all who've tried to help.
I experienced the same problem, I fixed this problem by adding Rtools dir into env variables:
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")

RQuantLib fails to load

I've recently updated all packages. Now RQuantLib fails to load. What can I do? I've tried to remove and reinstall the package in version 0.3.12 both from CRAN and from the source file, neither helps.
> library(RQuantLib)
Error : .onLoad failed in loadNamespace() for 'RQuantLib', details:
call: if (is.character(qc) && nchar(qc) > 1) {
error: missing value where TRUE/FALSE needed
In addition: Warning message:
running command 'bash -c 'type -p quantlib-config' 2>/dev/null' had status 1
Error: package or namespace load failed for ‘RQuantLib’
I'm working in RStudio with R 3.0.2 on Mac OS Mavericks. What can I do?
I had the same issue and after some hours of struggle I manage to use something not very rigorous but it works!
It seems that R has some issues evaluating system("bash -c 'type -p quantlib-config'").
After having installed QuantLib, typing the command bash -c 'type -p quantlib-config' in Terminal gives us the path of our quantlib-config which is for me /opt/local/bin/quantlib-config.
So I went back to my source folder for RQuantLib (version 0.4.0) and replaced qc in file R/inline.Rby:
qc <- as.character("/opt/local/bin/quantlib-config")
and rebuilt the package using the terminal command R CMD install RQuantLib/.
As I said, not very sexy but it works.
A restart of R and Rstudio is necessary.
Hope it helps the next ones and that this will be corrected in future versions.

Resources