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

What I think you want is as simple as
test.melted <- melt(test)

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.

wanted <- cast(test.melted, site + sampdate ~ 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:

c.tds.anal <- acast(m.tds.anal, site + variable ~ param)
Aggregation function missing: defaulting to length
head(c.tds.anal)
                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

______________________________________________
R-help@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.

Reply via email to