[R] self-written function

Christoph Scherber Christoph.Scherber at uni-jena.de
Fri Jan 28 09:28:26 CET 2005


Hi!

I´m using the function for a data frame, but up to now it only works 
with single vectors, such as

backsin(variable,grouping.factor)

Actually, you´re right, the "..." in the function definition is not 
needed...:-)

Regards
Christoph


Erin Hodgess wrote:

>Hello Christoph!
>
>I have a question about your question, please:
>
>In your first line of code, 
>backsin <- function(x,y,...){
>
>why do you have the three dots at the end?
>
>Also, what kind of data sets are you applying this to, please?
>
>Data frames or Matrixes?
>
>Thanks,
>Erin
>mailto: hodgess at gator.uhd.edu
>  
>
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