Reshape error in R -


i have gone through example posted others regarding reshaping data frame wide long.

my original dataframe has 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 reshape dataframe 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 keep getting error: error in reshapelong(data, idvar = idvar, timevar = timevar, varying = varying, : 'times' wrong length

as noted in comments reshape function not part of reshape2 package. columns named: dbh_05, dbh_06, dbh_09, dbh_10,... of times (and varying) arguments have no underscores. want

... varying= list( names(dfm)[12:47] ), times="dbh",  ... 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -