Ken,

Your error message
   > Error in aggregate.date.frame(as,dat.frame(x), ...): 
   > arguments must have same length
would arise if you called the 'Date' variable 'date'.
R is a case-sensitive language: 'date' is a function
object (with length 1) and 'Date' is the variable in
your data.frame Pilot (about 18000 long).  Did you
use different capitalizations of 'Date' in the with
and withless versions of the call to aggregate?

I noticed that your excerpt from the *.txt file contained
the header 'count' while Phil's code (which seemed to work
for you) used 'Count'.  One of those capilizations
must have been wrong.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -----Original Message-----
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Hall, Ken 
> (CDC/OSELS/NCPHI)
> Sent: Friday, August 20, 2010 7:40 AM
> To: Phil Spector
> Cc: r-help@r-project.org
> Subject: Re: [R] Aggregate Help
> 
> The first one worked great. Thanks for the quick response.
> 
> The second one, with the "with" statement, gave me the 
> following error:
> 
> Error in aggregate.date.frame(as,dat.frame(x), ...): 
> arguments must have
> same length
> 
> Ken
> 
> PS. What is the proper etiquette? Should I respond to you individually
> and the group, just the group or just individually? Or does 
> it depend on
> the context of my response?
> 
> -----Original Message-----
> From: Phil Spector [mailto:spec...@stat.berkeley.edu] 
> Sent: Thursday, August 19, 2010 5:00 PM
> To: Hall, Ken (CDC/OSELS/NCPHI)
> Cc: r-help@r-project.org
> Subject: Re: [R] Aggregate Help
> 
> Ken -
>     Try
> 
>  
> aggregate(Pilot$Count,list(Date=Pilot$Date,illness=Pilot$illness),sum)
> 
> If you don't want to keep typing "Pilot", use
> 
>    with(Pilot,aggregate(Count,list(Date=Date,illness=illness),sum))
> 
> Notice that the aggregated variable will be called "x" in the output
> data frame from aggregate.
> 
>                                       - Phil Spector
>                                        Statistical Computing Facility
>                                        Department of Statistics
>                                        UC Berkeley
>                                        spec...@stat.berkeley.edu
> 
> On Thu, 19 Aug 2010, Hall, Ken (CDC/OSELS/NCPHI) wrote:
> 
> > Please let me know if this is or is not the right place to ask these
> > types of questions.
> >
> > Warning: I am new to R by two days.
> >
> > I have a simple dataset.
> > I have loaded the dataset successfully using the following code:
> >
> > Filepath=(C:\temp\\pilot\dataset1.txt")
> > Pilot=read.table(filepath, header=TRUE)
> >
> > Dataset1.txt is delimited and looks like this:
> >
> > Date        illness count
> > 2006/01/01  derm    17
> > 2006/01/01  derm    35
> > 2006/01/02  derm    24
> > 2006/01/02  derm    80
> > .
> > .
> > .
> > Total records like this approximately 18,000
> >
> > I would like to use the aggregate function to sum the count 
> by similar
> > date and illness, so it should look like this after the aggregate
> >
> > 2006/01/01  derm    52
> > 2006/01/02  derm    104
> > .
> > .
> > .
> >
> > And, the illness changes to fever with the same pattern. I 
> would like
> to
> > aggregate the same illnesses by date in the same fashion.
> >
> > A nudge in the right direction would be appreciated.
> >
> > Thanks.
> >
> > Ken Hall
> > Computer Scientist
> > Division of Healthcare Information (DHI) (proposed)
> > Public Health Surveillance Program Office (proposed)
> > Office of Surveillance, Epidemiology, & Laboratory Services (OSELS)
> > (proposed)
> > Centers for Disease Control & Prevention (CDC)
> > k...@cdc.gov
> > Mobile: 404-993-3311
> > Office: 404-498-6839
> >
> >
> >
> >     [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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.
> >
> 
> ______________________________________________
> 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.
> 

______________________________________________
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