Hi chipmaney, Here is a suggestion: with(data, tapply(value, group, function(x) sd(x)/sqrt( length(x) ) ) ) * sqrt(fc$fc)
BTW, take a look at require(fortunes) fortune('dog') HTH, Jorge On Tue, Sep 29, 2009 at 6:29 PM, chipmaney <> wrote: > > #I have these data. Basically, I want to run a tapply to calculate the mean > and st. err. by factor. > #The problem is, I want to add a finite correction to the variance prior to > calculating the standard error. > #Now I know I could just do this in 3/4 steps by calculating the var, > applying the correction, then calculating the StErr. > > #However, I am trying to learn about functions and how they work. So if you > interested in puzzling the #following problem out.......... > > #I want to integrate the fc into the tapply() > #Since the fc is a different object than the tapply() object, how do I > integrate the fc into the function() > #call for the St.Err so that i get the formula ( fc*var(x)/length(x) > )^0.5 > for each factor???? > #I believe this takes some fidgeting with function(x), but I suck at > function building, > #particularly in this case of embedding a function() with multiple inputs > into an R function with only 1 #input, > #so I need help...maybe i need to input the tapply() function into my own > built function???? I don't know. > > > > data <- data.frame(group = c(rep("A",4), rep("B",5)), value = > c(40,45,24,34,234,243,435,324,244) ) > fc <- data.frame(group=c("A","B"), fc = c(0.75, 0.85)) > > Mean <- tapply(data$value,data$group, mean) > StErr <- tapply(data$value,data$group, function(x) ( var(x)/length(x) )^0.5 > ) #no fc yet > > -- > View this message in context: > http://www.nabble.com/Interesting-function-in-a-function-problem....-tp25672027p25672027.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.