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

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Jul 25 17:02:22 CEST 2012


Not really answering your posed question, but

a) reshape2 uses dcast and acast

b) The "cast" step of "melt-cast-melt" can invoke plyr, and it seems like MCM is just a very inefficient way for you to get at the plyr functionality. Perhaps you should take a more direct route to your goal?
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Johannes Radinger <JRadinger at gmx.at> wrote:

>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
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list