[R] Odp: trimmed mean

Petr PIKAL petr.pikal at precheza.cz
Fri Oct 5 13:43:03 CEST 2007


Hi

r-help-bounces at r-project.org napsal dne 05.10.2007 13:24:06:

> 
> Dear list,
> 
> I would like to calculate the trimmed mean for some subsets within a 
> data.frame (data). The list has already been very helpful, and I have 
> managed calculating the standard mean for the "Intensity" column based 
> on the "Name" column using
> 
> > avgs <-aggregate(data$Intensity, by = list(data$Name), mean)

Arguments to function are set like this

avgs <-aggregate(data$Intensity, by = list(data$Name), mean, trim = 0.1)

Regards
Petr


> 
> 
> but I cannot include the argument trim to mean()
> 
> > avgs <-aggregate(data$Intensidad, by = list(data$Name), mean
> (trim=0.1))
> Error in mean.default(trim = 0.1) : argument "x" is missing, with no 
> default
> > avgs <-aggregate(data$Intensity, by = list(data$Name), mean
> (data$Intensity, trim=0.1))
> Error in FUN(X[[1]], ...) : argument "INDEX" is missing, with no 
> default
> 
> What is the "INDEX" argument I am missing?
> 
> Thanks in advance,
> 
> David
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list