[英]Why does my numeric variable have dates and how do I convert the whole thing to xts?
我的output的頭像是這樣的; 當我執行 str(output) 時,它似乎是一個維度為 1 的數字,而且我似乎無法提取日期,顯然 xts(output) 沒有日期就無法工作。
2018-01-02 2018-01-03 2018-01-04 2018-01-05 2018-01-08 2018-01-09 2018-01-10
0.000 6511.339 6575.760 6584.575 6653.247 6676.615 6677.939 6662.670
您似乎有一個命名向量:
# create the vector `vector` with your values
vector <- c(6511.339, 6575.760, 6584.575, 6653.247, 6676.615, 6677.939, 6662.670)
# check vector (not named now)
vector
# add names to vector
names(vector) <- c("2018-01-02", "2018-01-03", "2018-01-04", "2018-01-05",
"2018-01-08"," 2018-01-09", "2018-01-10")
# now check named vector
vector
# get the names of the vector
names(vector)
#output:
[1] "2018-01-02" "2018-01-03" "2018-01-04" "2018-01-05" "2018-01-08" " 2018-01-09"
[7] "2018-01-10"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.