I am not able to install quantstrat package in r

261 Views Asked by At

I have just downloaded r and I am trying to download quantstrat. The only problem is that when I run the following code:

install.packages("devtools")   
require(devtools)   
install_github("braverock/blotter") 
install_github("braverock/quantstrat")

I obtain the this message error:

Error: Failed to install 'blotter' from GitHub:
  System command 'R' failed, exit status: 134, stdout + stderr (last 10 lines):
E> dyld: lazy symbol binding failed: Symbol not found: _utimensat
E>   Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib (which was built for Mac OS X 10.13)
E>   Expected in: /usr/lib/libSystem.B.dylib
E> 
E> dyld: Symbol not found: _utimensat
E>   Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib (which was built for Mac OS X 10.13)
E>   Expected in: /usr/lib/libSystem.B.dylib
E> 
E> /Library/Frameworks/R.framework/Resources/bin/build: line 10:   869 Done                    echo 'tools:::.build_packages()'
E>        870 Abort trap: 6           | R_DEFAULT_PACKAGES= LC_COLLATE=C "${R_HOME}/bin/R" --no-restore --no-echo --args ${args}
1

There are 1 best solutions below

0
Angus On

My solution was to install R 3.5 on top of R 4.02. Then I selected 3.5 by holding ctrl when opening Rstudio. It took a considerable time to create the build and update Rtools to version 3.5. But eventually I got it working and was able to run the code without problems...... assuming of course that you ran into problems with the Datacamp course as well.

See here: https://support.rstudio.com/hc/en-us/articles/200486138-Changing-R-versions-for-RStudio-desktop ... quantstrat working

library(quantstrat)
# Create initdate, from, and to strings
initdate <- "1999-01-01"
from <- "2003-01-01"
to <- "2015-12-31"
# Set the timezone to UTC
Sys.setenv(TZ = "UTC")
# Set the currency to USD 
currency("USD")

# Load the quantmod package
library(quantmod)
# Retrieve SPY from yahoo
getSymbols("SPY", from = from, to = to, src = "yahoo", adjust = T)

# Use stock() to initialize SPY and set currency to USD
stock("SPY", currency = "USD")