Hi
r-help-boun...@r-project.org napsal dne 16.07.2010 05:02:52:
> On Thu, Jul 15, 2010 at 10:45 PM, Murat Tasan wrote:
> > hi all - i'm just wondering what sort of code people write to
> > essentially performa an aggregate call, but with different functions
> > being applied to the various column
Hi:
A nice package for doing this sort of thing is doBy. Let's manufacture an
example
since you didn't provide one:
set.seed(126)
d <- data.frame(g = rep(letters[1:3], each = 10),
x1 = rnorm(30),
x2 = rnorm(30, mean = 5),
x3 = rnorm(30, mean = 10
On Thu, Jul 15, 2010 at 10:45 PM, Murat Tasan wrote:
> hi all - i'm just wondering what sort of code people write to
> essentially performa an aggregate call, but with different functions
> being applied to the various columns.
>
> for example, if i have a data frame x and would like to marginaliz
hi all - i'm just wondering what sort of code people write to
essentially performa an aggregate call, but with different functions
being applied to the various columns.
for example, if i have a data frame x and would like to marginalize by
a factor f for the rows, but apply mean() to col1 and medi
You might want to look at the summaryBy function in the doBy package
summaryBy(varname ~ zip, data=DATA,FUN=c(mean,median)
David Freedman
Mike ! wrote:
>
>
>
> I've got a data frame having numerical data by zip code:
>
> ZIP DATA
> 94111 12135.545
> 93105 321354.65654
> 941
Will something like this work for you:
> d <- read.table(textConnection("ZIP DATA
+ 94111 12135.545
+ 93105 321354.65654
+ 94111 545.555
+ 94706 558858.66"), header=TRUE)
> closeAllConnections()
> aggregate(d$DATA, list(Zip = d$ZIP), FUN=median, na.rm=T)
Zip x
1
I've got a data frame having numerical data by zip code:
ZIP DATA
94111 12135.545
93105 321354.65654
94111 545.555
94706 558858.66
... ...
I'm using this function to group records by ZIP and calculate the median of
DATA:
aggregate(d$DATA, list(Zip = d$ZIP), F
7 matches
Mail list logo