日期列将一个日期移回 - xts object + dplyr

时间:2015-12-10 22:18:00

标签: r xts

我今天偶然发现了这件事。我的日期列通过执行以下操作将一行移回。无法理解为什么会发生这种情况。原因是什么?

代码

> head(splitan)
             open   high    low  close volume value
2013-07-11 153.62 154.44 154.44 154.44      0     0
2013-07-12 154.44 156.51 156.51 156.51      0     0
2013-07-15 157.29 157.29 157.29 157.29      0     0
2013-07-16 157.29 157.17 157.17 157.17      0     0
2013-07-17 157.17 156.96 156.96 156.96      0     0
2013-07-18 156.96 157.01 157.01 157.01      0     0
> head(splitan %>% ggplot2::fortify() %>% mutate(Index = as.Date(Index, format = '%Y-%m-%d')))
       Index   open   high    low  close volume value
1 2013-07-10 153.62 154.44 154.44 154.44      0     0
2 2013-07-11 154.44 156.51 156.51 156.51      0     0
3 2013-07-14 157.29 157.29 157.29 157.29      0     0
4 2013-07-15 157.29 157.17 157.17 157.17      0     0
5 2013-07-16 157.17 156.96 156.96 156.96      0     0
6 2013-07-17 156.96 157.01 157.01 157.01      0     0
> str(splitan)
An ‘xts’ object on 2013-07-11/2015-12-04 containing:
  Data: num [1:626, 1:6] 154 154 157 157 157 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:6] "open" "high" "low" "close" ...
  Indexed by objects of class: [POSIXct,POSIXt] TZ: 
  Original class: 'data.frame'  
  xts Attributes:  
List of 1
 $ .RECLASS: logi TRUE

0 个答案:

没有答案