Hi Christoph On 28 Jan 2005 at 11:04, Christoph Scherber wrote:
> Hi! > > OK, here are some more details on the function: My dataframe consists > of several columns of categorical variables (let´s call them A,B,C) > plus a column with a response variable y (which is arcsine-square root > transformed proportions) > > I am now trying to write a function that automatically gives me the > back-transformed mean values + standard errors for y for each column > in the dataframe. Ideally, this would be something like > why not do it in several steps: omit <- !is.na(yourdf$y) transfy <- ((sin(yourdf$y[omit]))^2)*100 transm <- aggregatey(list(m=transfy), list(A,B,C,D), mean) transs <- aggregate(list(s=transfy), list(A,B,C,D), function(x) (sd(x)/sqrt(length(x))) # I hope I have corect no of () cbind(transm,transs$s) and if you feel like you can pack it to some function. Cheers Petr > tapply(y,list(A,B,C,D),backtransformed.mean) > > Here is the correct version of the function: > > backsin<-function(x,y){ > backtransf<-list() > > back<-((sin(x[x!="NA"]))^2)*100 > backtransf$mback<-tapply(back,y[x!="NA"],mean) > backtransf$sdback<-tapply(back,y[x!="NA"],std)/sqrt(length(y[x!="NA"]) > ) backtransf } > > > Regards, > Christoph > > > Petr Pikal wrote: > > >Hi > > > >I am not sure if anybody gave you a reply, but do you think you gave > >enough detail about your data, what you expect, what you did, what > >was the response and how it differ from expected output and best of > >all ***working*** example? > > > >BTW, what is stdev? > > > >If you wanted to compute standard deviation sd is enough. > > > >Cheers > >Petr > > > >On 27 Jan 2005 at 12:20, Christoph Scherber wrote: > > > > > > > >>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"],std)/sqrt(leng > >> th(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 > >> > >>______________________________________________ > >>R-help@stat.math.ethz.ch mailing list > >>https://stat.ethz.ch/mailman/listinfo/r-help > >>PLEASE do read the posting guide! > >>http://www.R-project.org/posting-guide.html > >> > >> > > > >Petr Pikal > >[EMAIL PROTECTED] > > > > > > > > > > > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html Petr Pikal [EMAIL PROTECTED] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html