データフレームをワイドからロングに再形成することに関して、他の人が投稿した例を見てきました。
元のデータフレームには次の列があります
Country,Trial_ID,Trial_name,seed.zone, Prov_name,Alt_min,Alt_max,Prov_ID,Replication, Tree_id Plot_id DBH_05, DBH_06, DBH_09, DBH_10, DBH_11, DBH_13, DBH_14, DBH_15, DBH_17, DBH_18, DBH_20, DBH_21, DBH_23, DBH_24, DBH_25, DBH_27, DBH_29, DBH_30, DBH_31, DBH_34, DBH_35, DBH_37
データフレームを次の列に再形成したい
Country,Trial_ID,Trial_name,seed.zone, Prov_name,Alt_min,Alt_max,Prov_ID , DBH, Age
library(reshape2)
mydata <- reshape(Database_Final,
idvar=c("Trial_name","Country", "Trial_ID",
"Trial_name","seed zone","Prov_name",
" Alt_min", "Alt_max","Prov_ID","Replication","Tree_id","Plot_id"),
varying = list( "DBH05","DBH06","DBH09","DBH10","DBH11","DBH13","DBH14",
"DBH15","DBH17","DBH18","DBH20","DBH21","DBH23",
"DBH24","DBH25","DBH27","DBH_29","DBH30","DBH31","DBH34","DBH35","DBH_37"),
v.names = "DBH",
timevar = "Age",
times = c( "DBH05","DBH06","DBH09","DBH10","DBH11","DBH13","DBH14",
"DBH15","DBH17","DBH18","DBH20","DBH21","DBH23",
"DBH24","DBH25","DBH27","DBH_29","DBH30","DBH31","DBH34","DBH35","DBH_37"),
direction = "long")
しかし、私はエラーが発生し続けます:Error in reshapeLong(data, idvar = idvar, timevar = timevar, varying = varying, : 'times' is wrong length