Re: [R] do.call without arguments?

2007-11-05 Thread Peter Dalgaard
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
   56789
23.61538 29.4 59.11538 59.96154 31.44828

$sd
   56789
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
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@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.


Re: [R] do.call without arguments?

2007-11-05 Thread Antje
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
56789
 23.61538 29.4 59.11538 59.96154 31.44828
 
 $sd
56789
 22.22445 18.20790 31.63584 39.68121 24.14182
 
 $median
  5  6  7  8  9
 18 23 60 52 23
 
 


__
R-help@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.