[R] self-written function

Christoph Scherber Christoph.Scherber at uni-jena.de
Thu Jan 27 12:20:25 CET 2005


Dear all,

I´ve got a simple self-written function to calculate the mean + s.e. 
from arcsine-transformed data:

backsin<-function(x,y,...){
 backtransf<-list()
 backtransf$back<-((sin(x[x!="NA"]))^2)*100
 backtransf$mback<-tapply(backtransf$back,y[x!="NA"],mean)
 backtransf$sdback<-tapply(backtransf$back,y[x!="NA"],stdev)/sqrt(length(y[x!="NA"]))
 backtransf
}

I would like to apply this function to whole datasets, such as

tapply(variable,list(A,B,C,D),backsin)

Of course, this doesn´t work with the way in which the backsin() 
function is specified.

Does anyone have suggestions on how I could improve my function?

Regards,
Christoph




More information about the R-help mailing list