Reshape error in R
I have gone through the example posted by others regarding reshaping data
frame from wide to long.
My original dataframe has the following columns
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
I want to reshape my dataframe into following columns
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")
but I keep getting the error: Error in reshapeLong(data, idvar = idvar,
timevar = timevar, varying = varying, : 'times' is wrong length
No comments:
Post a Comment