0

我刚刚下载了 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}
4

1 回答 1

0

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

见这里: https: //support.rstudio.com/hc/en-us/articles/200486138-Changing-R-versions-for-RStudio-desktop ... quantstrat 工作

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")
于 2020-11-23T15:17:38.750 回答