0
在問題中處理了類似問題link 我有數據框,其日期是列名。按列名對數據框的列進行排序日期
test = data.frame("01-Apr-16" = c(0, 2, 4, 7, 8),
"01-Jan-16" = c(4, 2, 4, 7, 8),
"01-Dec-16" = c(1, 3, 8, 3, 2))
我已轉換的日期,以相應的數字格式
new_names = apply(data.frame(names(test)), 1, function(x) as.Date(strptime(x,format = "%d-%b-%y")))
colnames(test) = new_names
溶液提供test[ , order(names(test))]
不作品。 有沒有解決問題的有效方法?
我已經從外部.csv文件中讀取數據幀,該文件在列名中保留了日期的原始格式。