> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Nordlund, Dan (DSHS/RDA)
> Sent: Thursday, October 27, 2011 10:47 AM
> To: r-help@r-project.org
> Subject: Re: [R] Syntax Check: rshape2 melt()
> 
> > -----Original Message-----
> > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > project.org] On Behalf Of Rich Shepard
> > Sent: Thursday, October 27, 2011 10:22 AM
> > To: r-help@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
> > > 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
> >
> 
> Rich,
> 
> I should apologize.  I saw rshape2 and just "glossed" over that and
> read rshape.  So I was using the rshape package rather than rshape2.  I
> don't know the relationship between those two packages and/or how they
> differ.  I am sure that there are others that can help you out here.
> 
> Dan
> 
I need more coffee.  That should have been reshape and reshape2, not rshape and 
rshape2.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


______________________________________________
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