[R] reshape -> reshape 2: function cast changed?

Johannes Radinger JRadinger at gmx.at
Wed Jul 25 12:14:54 CEST 2012


Hi,

I used to use reshape and moved to reshape2 (R 2.15.1). Now I tried some of my older scripts and was surprised that my cast function wasn't working like before.
What I did/want to do:
1) Melt a dataframe based on a vector specifying column names as measure.vars. Thats working so far:
dfm <- melt(df, measure.vars=n, variable_name = "species", na.rm = FALSE)

2) Recast the dataframe:
dfc <- cast(dfm, Var1 + Var2 + Var3 + Var4 ~ species,max) # with reshape
dfc <- dcast(dfm, Var1 + Var2 + Var3 + Var4 ~ species,max) # with reshape2

but then I get (this is new to reshape2!) a warning message:
In .fun(.value[0], ...) : no non-missing arguments to max; returning -Inf

The result seems to be similar (but I haven't checked it yet properly)? A message to ignore?

I use melt/cast/melt e.g. for multiple measurements (similar name in one column) to get only one row (one measurement) with e.g. the max value. Of course during the procedure I can also use cast/melt to drop columns that are not relevant for further processing.

/Johannes



More information about the R-help mailing list