Skip to content
Prev 275693 / 398506 Next

Syntax Check: rshape2 melt()

On Thu, 27 Oct 2011, Nordlund, Dan (DSHS/RDA) wrote:

            
Dan,

   I see the difference this syntax makes; sampdate is the variable
associated with the value (quant) for a specific ID pair of site and param.
This, unfortunately, doesn't work:

c.tds.anal <- cast(m.tds.anal, site + sampdate ~ param)
Error: could not find function "cast"

   ?cast has an example using acast() so I tried that:

c.tds.anal <- acast(m.tds.anal, site + sampdate ~ param)
Error in eval(expr, envir, enclos) : object 'sampdate' not found

   Changing 'sampdate' to 'variable' produces results, but not what's needed:
Aggregation function missing: defaulting to length
Ca Cl Cond Mg Na SO4 TDS
BC-0.5_sampdate  1  1    3  1  0   3   3
BC-0.5_quant     1  1    3  1  0   3   3
BC-1_sampdate    8  8   11  8  7  10  10
BC-1_quant       8  8   11  8  7  10  10
BC-1.5_sampdate  3  4    6  3  0   6   6
BC-1.5_quant     3  4    6  3  0   6   6

   Now that I better understand melt(), I'll read ?cast.

Thanks very much,

Rich