2017-05-08 1 views

답변

1

, 이것은 단지 몇 가지 조치를 취하고 있습니다. 로드하는 경우 dplyr, 당신은 그것을 파이프 수 있습니다. 표가 있다고 가정하면 df ...

library(dplyr) 
library(tidyr) 
library(zoo) 

df %>% 
    # use tidyr to convert the wide data to long 
    gather(key = month, value = value, -Year) %>% 
    # use zoo to create a year-month index 
    mutate(yearmon = as.yearmon(paste(month, Year))) %>% 
    # now make a zoo object of the values with that index 
    with(., zoo(value, order.by = yearmon)) 
관련 문제