Try this:
aggregate(DF[c('data', 'data2')], DF[ 'years'], FUN = sum, na.rm = TRUE)
aggregate(DF[c('data', 'data2')], list(as.character(factor(DF[, 'years'],
labels = c('5-7', '5-7', '5-7', 8, FUN = sum, na.rm = TRUE)
On Sun, Apr 25, 2010 at 3:29 AM, steven mosher mosherste...@gmail.comwrote:
I have a 43MB dataframe ( 5 variables) and I'm trying to summarize subsets
of the data.
I've RTFM ( not very clear) and looked at a variety of samples but cant seem
to figure out
how to make these functions work.
A sample of what I want to do would be this:
ids-seq(1,50)
Here is one solution for your question:
mean.data - with(DF, tapply(data, years, mean, na.rm = T))
mean.data2 - with(DF, tapply(data2, years, mean, na.rm = T))
cbind(mean.data , mean.data2)
Another one would be for you to read about the package plyr (which is better
for this job, actually)
And
Thanks I'll try that, still need to understand how the other functions
work.. just to satisfy myself..thanks again
On Sun, Apr 25, 2010 at 12:06 AM, Tal Galili tal.gal...@gmail.com wrote:
Here is one solution for your question:
mean.data - with(DF, tapply(data, years, mean, na.rm = T))
.
--- On Sun, 4/25/10, steven mosher mosherste...@gmail.com wrote:
From: steven mosher mosherste...@gmail.com
Subject: [R] Noobie question on aggregate tapply and by
To: r-help r-help@r-project.org
Received: Sunday, April 25, 2010, 2:29 AM
I have a 43MB dataframe ( 5
variables) and I'm trying
')
DF$years - recode(DF$years, c(5,6,7)= '5-7')
DF
You may also want to have a look at the reshape and plyr packages.
--- On Sun, 4/25/10, steven mosher mosherste...@gmail.com wrote:
From: steven mosher mosherste...@gmail.com
Subject: [R] Noobie question on aggregate tapply
6 matches
Mail list logo