[R] do.call without arguments?

Antje niederlein-rstat at yahoo.de
Mon Nov 5 11:40:54 CET 2007


Thank you very much! This is exactly what I need... I did not know that there 
is such a simple way :)

Antje


Peter Dalgaard schrieb:
> 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
> 
> 
>



More information about the R-help mailing list