Installation of RQuantLib - r

I tried to install RQuantLib from RStudio, but it has given me problems.
I updated my R version to 3.3.1 and tried to use the usual way of installing a package (install.packages("RQuantLib")) as recommended on the webpage of the author (http://dirk.eddelbuettel.com/code/rquantlib.html). However, it gave the following error message :
Warning in install.packages :
package ‘RQuantLib’ is not available (for R version 3.3.1)
I tried installing it on different computers too, but I got the same error message.
Does anyone else experience the same problem or has any idea what could have gone wrong? Thank you!

You are on Windows per your comment. As per this section of the README.md
Windows Binaries
Starting with release 0.4.3, binaries are provided via the ghrr drat repo and can be installed as
R> drat::addRepo("ghrr") # maybe use 'install.packages("drat")' first
R> install.packages(RQuantLib)
you can install a pre-built Windows binaries -- which I just updated for QuantLib 1.8.1 -- from this non-CRAN repo.
Edit: Apparently one now has to say type="binary" even on Windows. Here is a log from a virtual machine I keep:
R> drat::addRepo("ghrr")
R> options("repos")
$repos
CRAN ghrr
"https://cloud.r-project.org" "https://ghrr.github.io/drat/"
R> install.packages("RQuantLib", type="binary")
Installing package into c:/opt/R-library
(as lib is unspecified)
trying URL 'https://ghrr.github.io/drat/bin/windows/contrib/3.3/RQuantLib_0.4.3.zip'
Content type 'application/zip' length 7993848 bytes (7.6 MB)
downloaded 7.6 MB
package RQuantLib successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\[redacted]\AppData\Local\Temp\RtmpAHvBmo\downloaded_packages
R>
I'll update the README.md web page.

Related

What does this error mean when I try and install the Mosaic package in R?

When I try and install the mosaic package in R studio, I get the following messages:
> install.packages('mosaic', dependencies = TRUE)
Warning in install.packages :
dependencies ‘latticeExtra’, ‘fastR’ are not available
also installing the dependency ‘rgl’
There are binary versions available but the source versions are later:
binary source needs_compilation
rgl 0.100.50 0.100.54 TRUE
mosaic 1.5.0 1.6.0 FALSE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) No
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/rgl_0.100.50.tgz'
Content type 'application/x-gzip' length 4709273 bytes (4.5 MB)
==================================================
downloaded 4.5 MB
The downloaded binary packages are in
/var/folders/c8/lyjrvw_x18q2trr07z2s7m8w0000gn/T//RtmpOfzCf6/downloaded_packages
installing the source package ‘mosaic’
trying URL 'https://cran.rstudio.com/src/contrib/mosaic_1.6.0.tar.gz'
Content type 'application/x-gzip' length 12425406 bytes (11.8 MB)
==================================================
downloaded 11.8 MB
ERROR: dependency ‘latticeExtra’ is not available for package ‘mosaic’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mosaic’
Warning in install.packages :
installation of package ‘mosaic’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/c8/lyjrvw_x18q2trr07z2s7m8w0000gn/T/RtmpOfzCf6/downloaded_packages’
How can I avoid this? I have tried saying both Yes and no on the following line:
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) No
And get an error both times. When I say yes and it attempts to install rgl I repeatedly get this message:
You have not agreed to the Xcode license agreements, please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode license agreements.
When I run xcodebuild -license in my terminal window it asks me for a password but does not allow me to type anything in the password slot and does not continue to install.
Is there any other way I can install the mosaic package?
I'm clearing a backlog as my semester winds down. Sorry I didn't get to this sooner.
Short answer: a new version of mosaic is on CRAN, and this issue should go away if you install the new version.
The particular issue you were having looks like it was related to an archived package that was suggested (i.e., not required) by the mosaic package. That package is no longer in the dependency list for mosaic.
In general, when I have issues like this, I often find that manually installing the packages listed in imports: and depends: in the DESCRIPTION file of a package will either (a) resolve the problem or (b) identify exactly where the problem lies.
It seems its dependencies are not installed yet. Maybe install the following packages first: latticeExtra and fastR
install.packages("latticeExtra")
install.packages("fastR")

Error in library(ggplot2) : there is no package called ‘ggplot2’ Execution halted

I updated my system from ubuntu 18.04 to 18.10. everything worked fine on my previous version, but updating removed all my R libraries.
I want to reinstall them, but when I try and install anything, i.e.
install.packages("data.table")
Installing package into ‘/home/sam/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'http://cran.revolutionanalytics.com/src/contrib/data.table_1.11.8.tar.gz'
Content type 'application/octet-stream' length 3262853 bytes (3.1 MB)
==================================================
downloaded 3.1 MB
Error in library(ggplot2) : there is no package called ‘ggplot2’
Execution halted
The downloaded source packages are in
‘/tmp/RtmpYnxoaQ/downloaded_packages’
Warning message:
In install.packages("data.table") :
installation of package ‘data.table’ had non-zero exit status
I get some error about ggplot2 not being present, even though i'm not trying to install it. Currently I haven't managed to isntall any libraries.
I am using R version 3.5.1 (2018-07-02) -- "Feather Spray". which is the most recent version.
Any idea why this is happening?
#Roland was correct - the issue here was that I was trying to load libraries from my .Rprofile that weren't installed. Removing these lines from the .Rprofile stopped the error message.
You need to update your R version and do this but you'll need install all packages again:
Tool > Global Options > R version (CHANGE) > Select "Use your machine's default version of R..."
I did two things and it's work. Hopefully, it does for you also
a) Update your R and do this.
Tool > Global Options > R version (CHANGE) > Select "Choose the specific version of R...". Mostly just choose the latest version.
b) Restart your app after.
Install ggplot2 using this command:
install.packages("ggplot2", dependencies = TRUE)
library(ggplot2)

installation path not writable R, unable to update packages

I am trying to install Bioconductor into R, using the code on their website. When I type in the code (see bellow) I get an error message saying that some packages can't be updated, the installation path is unwriteable.
> ## try http:// if https:// URLs are not supported
> source("https://bioconductor.org/biocLite.R")
Bioconductor version 3.4 (BiocInstaller 1.24.0), ?biocLite for help
> biocLite()
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.2 (2016-10-31).
installation path not writeable, unable to update packages: Matrix, mgcv,
survival
I can install these package by going to packages/install packages.
> utils:::menuInstallPkgs()
trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/Matrix_1.2-8.zip'
Content type 'application/zip' length 2775038 bytes (2.6 MB)
downloaded 2.6 MB
trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/mgcv_1.8- 16.zip'
Content type 'application/zip' length 2346257 bytes (2.2 MB)
downloaded 2.2 MB
trying URL 'https://www.stats.bris.ac.uk/R/bin/windows/contrib/3.3/survival_2.40-1.zip'
Content type 'application/zip' length 5109948 bytes (4.9 MB)
downloaded 4.9 MB
package ‘Matrix’ successfully unpacked and MD5 sums checked
package ‘mgcv’ successfully unpacked and MD5 sums checked
package ‘survival’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\stxeb8\AppData\Local\Temp\Rtmp2tQZ4v\downloaded_packages
I can then go to packages/ load packages and load them succesfully and search and see that the packages are there.
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Loading required package: nlme
This is mgcv 1.8-16. For overview type 'help("mgcv-package")'.
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
> search()
[1] ".GlobalEnv" "package:survival" "package:mgcv"
[4] "package:nlme" "package:Matrix" "package:BiocInstaller"
[7] "package:stats" "package:graphics" "package:grDevices"
[10] "package:utils" "package:datasets" "package:methods"
[13] "Autoloads" "package:base"
But then when I go to install bioconductor it gives me the same error message that Matrix, mgcv and survival aren't able to be updated.
> ## try http:// if https:// URLs are not supported
> source("https://bioconductor.org/biocLite.R")
Bioconductor version 3.4 (BiocInstaller 1.24.0), ?biocLite for help
> biocLite()
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.2 (2016-10-31).
installation path not writeable, unable to update packages: Matrix, mgcv,
survival
What can I do to be able to update these packages so I can install bioconductor?
In general, I would advise against changing the permission in system folders, because R should work without additional administrative rights.
Thus I would likewise advise against installing packages using administrative rights, as you would be required to do so in the future every time you have to update these packages!
To backtrace this issue and prevent to minimize it in future updates, you should perform the following steps:
Note which packages that fail to update (already shown in the error message).
Locate the folders where all R packages are installed using .libPaths(). This should provide two results, a destination in your home folder and a system folder.
"/home/USER/R/x86_64-pc-linux-gnu-library/X.X" "/usr/lib/R/library"
Install the packages with install.packages(c("PKG1", "PKG2", "PKG3")) or BiocManager::install(c("PKG1", "PKG2", "PKG3"))*
Only If you have administrator rights: Manually remove the older package folders from the system folder ("/usr/lib/R/library"), using administrator rights (sudo) OR enter R with administrator rights One last time and run remove.packages(c("PKG1", "PKG2", "PKG3"), lib = "/usr/lib/R/library").
*If there are issues with the installation path, add the argument , lib = "/home/USER/R/x86_64-pc-linux-gnu-library/X.X" to either of the install functions in step 3. This argument explicitly states to install in your home folder.
There is a single issue with this approach, at least with the official R repository on Arch Linux: Whenever R is updated, the updated version still includes packages in the system folder, that can't be updated without administrative rights. Therefore for each R update, this procedure must be repeated. I'm especially looking at you survival!!!
*Edit: It is important to note that biocLite is no longer the recommended tool for installing BioConductor packages. You should instead use BiocManager, which is in the official CRAN repository (install.packages("BiocManager")).
**Second edit: As this answer still receives votes, I have updated and cleaned up the answer.
It was a permission issue for me. First, I identified where the packages were installed using installed.packages()[, c("Package", "LibPath")]. This outputs a long 2 column matrix with the names and locations of the packages. Then you will see where the offending packages are. In my case, they were at /usr/lib/R/site-library and /usr/lib/R/library. Then I changed the permission of these folders by chmod (I used chmod -R 777 on the main R folder, this is my personal computer, so security is not a big concern here I think).
If you are running R/Rstudio on Windows, then just open R/Rstudio as administrator. Right click on the icon then run as administrator
It looks like several 'recommended' packages are installed in two places -- maybe by an administrator account in a directory you don't have write access to, and then by RStudio in a directory where you do have write access. biocLite() is complaining about the former.
Unless biocLite() complains about a Bioconductor package that cannot be installed (different from cannot be updated), there is no problem and basic Bioconductor packages have been successfully installed. Check out https://support.bioconductor.org for future Bioconductor-related support.
One solution is to open a terminal and load R using admin rights
sudo R
update.packages()
source("https://bioconductor.org/biocLite.R")
biocLite()
Then you can update. But careful. This can create packages by the admin in a directory supposed to be owned by a user.
In this case, instead of loading R as root (which is solving the problem until the next update), check the .libPaths(). You will have a list of directories.
.libPaths()
"/home/it_s_me/R/x86_64-pc-linux-gnu-library/3.4" "/usr/lib/R/library"
In my case, all packages in "/usr/lib/R/library" are owned by root, and all except one are owned by a normal user (not root) at "/home/itsame/R/x86_64-pc-linux-gnu-library/3.4".
If you have admin rights, an easy solution may be to run chown in all the places: For example, I had trouble updating the curl package. I used:
sudo chown -R it_s_me /home/it_s_me/R/x86_64-pc-linux-gnu-library/3.4/curl/
I had a similar problem with other Bioconductor packages and the solution was simpler than I thought. I had to install some OS packages pointed out on my log: libcurl-dev, libcurl4-openssl-dev, libssl-dev.
My advice is to check your R log and look for "Configuration failed because [PACKAGE] was not found. Try installing".
Since with the version of R 3.6.1 the script http://bioconductor.org/biocLite.R returns this message " Error: With R version 3.5 or greater, install Bioconductor packages using BiocManager; see https://bioconductor.org/install " I solved the problem with the following steps:
Get the list of directories used by R to install libraries and
choose the one with write permissions using: .libPaths()
Installing the "BiocManager" library using: install.packages("BiocManager")
Installation of the library "bioconductor" by forcing the directory
with write permissions using: BiocManager::install("Rgraphviz", lib = "C:/Users/tizbet/Documents/R/win-library/3.6")
I worked on the following R installation:
platform x86_64-w64-mingw32, arch x86_64, os mingw32, system x86_64, mingw32, version.string R version 3.6.1 (2019-07-05)
I was inspired by the Kasper Thystrup Karstensen answer
Whenever you want to work on an R-code where packages need to be installed: -
Windows: Open R-studio as 'Run as administrator' [Right click on the icon]
Linux: Run as sudo user; else get writing rights from the administrator
Ubuntu:
sudo apt install libcurl-dev
Fedora:
sudo dnf install libcurl-devel

Why is install.package() - building the package from scratch?

I installed RStudio and R recently on a new laptop
I installed RTools after I noticed that my "packages" (it's source code) - was being downloaded in a temp. folder under "Users...\AppData\ etc. and I couldn't find the actual package and use them.
The RTools then builds the package from source - I think
This did not happen with my earlier RStudio and R isntalls. The packages were downloaded "cleanly" - I don't remember it going to through the source code build process
> install.packages("caret")
also installing the dependencies ‘nloptr’, ‘lme4’, ‘pbkrtest’, ‘car’
Packages which are only available in source form, and may need compilation of
C/C++/Fortran: ‘nloptr’ ‘lme4’ ‘caret’
Do you want to attempt to install these from sources?
When I say 'y' to this question - it builds it all right.
Versions:
OS: Windows 10
RStudio: 0.99.903
R: 3.3.1
(P.S. I have not been able to install the 'caret' package, the others I could going through this process.)
this worked for me:
I installed the package directly from the windows binary zip file:
LINK <- "https://cran.r-project.org/bin/windows/contrib/3.3/caret_6.0-71.zip"
install.packages(LINK, repos =NULL)
The links to binaries were found at: https://cran.r-project.org/
See under Software > R Binaries

R Newbie Confused about Install Packages

I am somewhat new to R, and I thought I understood how to install packages from CRAN mirrors and from source files, but now I am stumped. I currently am using R 2.10.0 on a Windows 7 32-bit machine.
I want to try to use the RGoogleAnalytics package found here and am trying to follow the instructions. They instruct us to install both RCurl and the XML packages from omegahat. For example,
install.packages("RCurl", repos = "http://www.omegahat.org/R")
however this does not work, as I get the following error:
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘RCurl’ is not available
When I try this instead:
install.packages("RCurl", repos = "http://www.omegahat.org/R", type="source")
I get the following error after the file downloads. I previously had version 1.0 and that is restored.
trying URL 'http://www.omegahat.org/R/src/contrib/RCurl_1.5-0.tar.gz'
Content type 'application/x-gzip' length 735041 bytes (717 Kb)
opened URL
downloaded 717 Kb
* installing *source* package 'RCurl' ...
Warning in system("sh ./configure.win") : sh not found
ERROR: configuration failed for package 'RCurl'
* removing 'C:/PROGRA~1/R/R-210~1.0/library/RCurl'
* restoring previous 'C:/PROGRA~1/R/R-210~1.0/library/RCurl'
The downloaded packages are in
‘C:\Users\Brock\AppData\Local\Temp\Rtmpc9wt5N\downloaded_packages’
Warning message:
In install.packages("RCurl", repos = "http://www.omegahat.org/R", :
installation of package 'RCurl' had non-zero exit status
Without going into details, I haven't been able to use the RGoogleAnalytics package as I get the same error that is found in this post. I simply am trying to exhaust every possible option to get around the error.
Any help or insight you can provide will be greatly appreciated!
The RCurl project page on CRAN says the Windows binary is not available. The ReadMe points you to a page maintained by Professor Ripley, where he provides binaries of RCurl and several other packages that have special build needs on Windows. However, he only provides them for the most recent major revision of R, so you would need to upgrade to R-2.12.0 to install them from his page.
If you want to build packages from source on Windows, you need to install Rtools first. It looks like you haven't done that. Even if you had them installed, it will still require extra steps to build RCurl on Windows... else the Windows binary would already be on CRAN.
Your best bet is probably to upgrade R and install RCurl from Prof. Ripley's page.
You are probably missing the components to build packages under Windows:
http://www.murdoch-sutherland.com/Rtools/
According to RCurl FAQ, either
curl-config is not found in your path
or
curl-config and related devlopment libraries (libcurl) are not installed.

Resources