简体   繁体   English

我无法在 r 中安装 quantstrat 包

[英]I am not able to install quantstrat package in r

I have just downloaded r and I am trying to download quantstrat.我刚刚下载了 r,我正在尝试下载 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}

My solution was to install R 3.5 on top of R 4.02.我的解决方案是在 R 4.02 之上安装 R 3.5。 Then I selected 3.5 by holding ctrl when opening Rstudio.然后我在打开 Rstudio 时按住 ctrl 选择了 3.5。 It took a considerable time to create the build and update Rtools to version 3.5.创建构建并将 Rtools 更新到版本 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.但最终我让它工作了,并且能够毫无问题地运行代码......当然,假设你也遇到了 Datacamp 课程的问题。

See here: https://support.rstudio.com/hc/en-us/articles/200486138-Changing-R-versions-for-RStudio-desktop ... quantstrat working请参阅此处: 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")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM