Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在这里做错了什么?
library(quantmod) getSymbols('^GSPC') b <- tail(GSPC, 20) #for brevity is.factor(factor(Cl(b), labels=c('A'))) > TRUE b$f <- factor(Cl(b), labels=c('A')) is.factor(b$f) [1] FALSE
我希望我的 xts/quantmod 对象中的一列成为一个因素。我不知道为什么它不起作用。
谢谢
它不起作用,因为 xts/zoo 对象是具有索引属性的矩阵,您不能在矩阵中混合类型。 GSPC包含数字数据,因此您只能添加数字列。
GSPC