2
我有一個data.frame
72月時間序列堆疊長形式(垂直)。我已經使用split爲每個系列創建list
的data.frames
。我現在想要採用每個data.frame
並使用數據幀中包含的value
和date
將其轉換爲xts
對象。該列表有72個數據框,我想要一個72個xts對象的返回列表。該列表看起來像:列表data.frames的列出XTS的對象
LAUPS55030003:'data.frame': 282 obs. of 6 variables:
..$ series_id : chr [1:282] "LAUPS55030003" "LAUPS55030003" "LAUPS55030003"
...
..$ year : int [1:282] 1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 ...
..$ period : chr [1:282] "01" "02" "03" "04" ...
..$ value : num [1:282] 12.6 5.3 5.3 4.7 4.7 4.7 5.5 4.6 4.6 4.3 ...
..$ footnote_codes: chr [1:282] "" "" "" "" ...
..$ date : Date[1:282], format: "1990-01-01" "1990-02-01" "1990-03-01" "1990-0
我試過使用llply和lapply無濟於事,甚至ddply。嘗試編寫as.xts函數時出現錯誤。我認爲我在正確的軌道上,但我的語法顯然是關閉的。
我也試過:
lx <- dlply(ur, .(ur$series_id), .fun=(as.xts), ur[,4], order.by=ur[,6])
指針?