[R] do.call without arguments?
Peter Dalgaard
P.Dalgaard at biostat.ku.dk
Mon Nov 5 11:29:38 CET 2007
Antje wrote:
> Hello,
>
> I have a vector containing strings of simple operation methods.
>
> methods <- c("mean","sd","median") e.g.
>
> Now, I'd like to apply these methods to my data and I thought, I could make a
> do.call. But these methods don't need any further arguments... Do I have to
> create an empty argument list?
>
> I wanted to use a tapply( data, factor, ??? do.call ??? )
>
> Can anybody help how to solve this problem?
>
>
Not sure what you mean by "any further arguments", but I wouldn't use
do.call here:
> names(methods)<-methods
> with(airquality,
+ lapply(methods, function(f) tapply(Ozone,Month,FUN=f, na.rm=T)))
$mean
5 6 7 8 9
23.61538 29.44444 59.11538 59.96154 31.44828
$sd
5 6 7 8 9
22.22445 18.20790 31.63584 39.68121 24.14182
$median
5 6 7 8 9
18 23 60 52 23
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list