我无法在r中安装quantstrat包



我刚刚下载了r,正在尝试下载quantstrat。唯一的问题是,当我运行以下代码时:

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

我得到这个消息错误:

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}

我的解决方案是在R 4.02之上安装R 3.5。然后我在打开Rstudio时按住ctrl选择了3.5。创建构建并将Rtools更新到3.5版花费了相当长的时间。但最终我成功了,并且能够毫无问题地运行代码。。。。。。当然,假设您在Datacap课程中也遇到了问题。

请参见此处:https://support.rstudio.com/hc/en-us/articles/200486138-Changing-R-versions-for-RStudio-desktop。。。量子工作

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")

相关内容

  • 没有找到相关文章

最新更新