全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2940 2
2018-06-21
HS300 <- read_csv("HS300.csv", col_names = TRUE)
head(HS300)
HS300 <- as.vector(HS300)
#Create a vector of equal weights
equal_weights <- rep(1 / ncol(HS300_2), ncol(HS300_2))
#Compute the benchmark returns
benchmark_returns <- HS300 %>%
  Return.portfolio(weights = equal_weights,
                   rebalance_on = "quarters")

不知道为什么报错:
Error in checkData(R, method = "xts") :
  The data cannot be converted into a time series.  If you are trying to pass in names from a data object with one column, you should use the form 'data[rows, columns, drop = FALSE]'.  Rownames should have standard date formats, such as '1985-03-15'.
In addition: Warning message:
In if (class(x) == "numeric") { :
  the condition has length > 1 and only the first element will be used

请高手们解答一下该如何改正,谢谢!


附件列表

HS300.xlsx

大小:12.42 KB

 马上下载

数据

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2018-6-21 23:13:00
you need to convert date into time series format first, otherwise, they are strings to R.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-6-22 08:12:09
为了提高别人解决你所提问题的兴趣与效率,请附带能够重复错误的数据。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群