-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of Rich Shepard
Sent: Thursday, October 27, 2011 10:22 AM
To: r-help at r-project.org
Subject: Re: [R] Syntax Check: rshape2 melt()
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
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