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
请高手们解答一下该如何改正,谢谢!