Re: [R] Syntax Check: rshape2 melt() [RESOLVED]

2011-10-28 Thread Rich Shepard
On Fri, 28 Oct 2011, Rich Shepard wrote: May not be until Monday that I return with results on this effort as I'm going to be carfully checking and documenting each step and its results. Dan, et al.: Got it working properly now. Took a different approach after re-reading the source data in

Re: [R] Syntax Check: rshape2 melt()

2011-10-28 Thread Rich Shepard
On Thu, 27 Oct 2011, Rich Shepard wrote: Nope. Can't. Dan et al.: I apologize for the certainty; anything can happen to data as un-intended consequences of processing. I will write that there _should_ be no duplicates. What I'm going to do is re-read the data frame from the source text

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Thu, 27 Oct 2011, Nordlund, Dan (DSHS/RDA) wrote: I will be leaving work shortly, and won't be able to look at this again until tomorrow some time. However, I went back and reread the help page on dcast. Here is part of that page. fun.aggregate aggregation function needed if variables do

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Nordlund, Dan (DSHS/RDA)
> -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 4:29 PM > To: r-help@r-project.org > Subject: Re: [R] Syntax Check: rshape2 melt() > > On Thu, 27 Oct 2

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Thu, 27 Oct 2011, Nordlund, Dan (DSHS/RDA) wrote: It appears that what you did differently was to dcast the un-melted data. In addition, you shouldn't need to turn your dates into factors. I assume that your unaltered data is in tds.anal. Dan, It's been that sort of a day when that mig

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Nordlund, Dan (DSHS/RDA)
> -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 2:41 PM > To: r-help@r-project.org > Subject: Re: [R] Syntax Check: rshape2 melt() > > On Thu, 27 Oct 2

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Thu, 27 Oct 2011, Rich Shepard wrote: So I did the conversion and melting the long way: tds.a <- tds.anal tds.a$sampdate <- factor(tds.a$sampdate) I didn't copy the melt command: tds.anal.m <- melt(tds.a) However, ... c.tds.anal <- dcast(tds.a, site + sampdate ~ param, value_var =

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Thu, 27 Oct 2011, Dennis Murphy wrote: # Define param so that all of its levels are represented: tds.a <- within(tds.a, { param = factor(param, levels = c('TDS', 'Cond', 'Mg', 'Ca', 'Cl', 'Na', 'SO4')) sampdate = as.Date(sampdate) } ) Dennis, This produces an error:

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Fri, 28 Oct 2011, Hadley Wickham wrote: See here: https://github.com/hadley/reshape Thanks, Hadley. 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.or

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Hadley Wickham
>> 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. > >  I, too, don't know how the two packages 'reshape, The Orignal' and > 'reshape2, Reboote

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Dennis Murphy
Try this, based on your small example: > tds.a <- read.table(textConnection(" + site sampdate param quant + 1UDS-O 2006-12-06 TDS 10800 + 4 STC-FS 1996-06-14 Cond 280 + 7UDS-O 2007-10-04Mg 1620 + 9UDS-O 2007-10-04 SO4 7580 + 19 JCM-10B 2007-06-21Ca79 + 20

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Nordlund, Dan (DSHS/RDA)
> -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 12:00 PM > To: r-help@r-project.org > Subject: Re: [R] Syntax Check: rshape2 melt() > > On Thu, 27 Oct 2

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Thu, 27 Oct 2011, Nordlund, Dan (DSHS/RDA) wrote: I read in the sample data that you put in an earlier post. tds.anal <- read.table('clipboard',header=TRUE) tds.anal site sampdate param quant 1UDS-O 2006-12-06 TDS 10800 4 STC-FS 1996-06-14 Cond 280 7UDS-O 2007-10-04

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Thu, 27 Oct 2011, Nordlund, Dan (DSHS/RDA) wrote: What I think you want is as simple as test.melted <- melt(test) Dan, et al.: No, it's not that simple. Unfortunately. I've tried various combinations of id.vars, measure.vars, and variable, but just cannot get the dates to display in the

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Nordlund, Dan (DSHS/RDA)
> -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 11:17 AM > To: r-help@r-project.org > Subject: Re: [R] Syntax Check: rshape2 melt() > > On Thu, 27 Oct 2

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Thu, 27 Oct 2011, Nordlund, Dan (DSHS/RDA) wrote: You should be able to get what you want using the dcast function (I think). test.melted <- melt(tds.anal) dcast(test.melted, site + sampdate ~ param) Dan, I don't think the data frame melted properly. I tried the dcast() but sampdate is

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Nordlund, Dan (DSHS/RDA)
> -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:56 AM > To: r-help@r-project.org > Subject: Re: [R] Syntax Check: rshape2 melt() > > On Thu, 27 Oct 2

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
On Thu, 27 Oct 2011, Nordlund, Dan (DSHS/RDA) wrote: I should apologize. I saw rshape2 and just "glossed" over that and read rshape. Dan, Apparently the 'e' in the subject line fell off. It's 'reshape2'. So I was using the rshape package rather than rshape2. I don't know the relationshi

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Nordlund, Dan (DSHS/RDA)
> -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() > >

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Nordlund, Dan (DSHS/RDA)
> -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 2

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
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

Re: [R] Syntax Check: rshape2 melt()

2011-10-27 Thread Nordlund, Dan (DSHS/RDA)
> -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 8:26 AM > To: r-help@r-project.org > Subject: [R] Syntax Check: rshape2 melt() > > >This is my

[R] Syntax Check: rshape2 melt()

2011-10-27 Thread Rich Shepard
This is my first excursion into using reshape2 and I want to ensure that the melt() function call is syntactically correct. The unmodifed data frame is organized this way: head(tds.anal) site sampdate param quant 1UDS-O 2006-12-06 TDS 10800 4 STC-FS 1996-06-14 Cond 280 7