2017-05-08 7 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)) 
関連する問題