Displaying 1 result from an estimated 1 matches for "meanstderr".
2007 Oct 17
1
passing arguments to functions within functions
...vice would be greatly appreciated.
Thanks, Dan
# some example data
df=expand.grid(rep=1:4, fac1=c("a","b"), fac2=c("c","d"), fac3=c
("e","f"))
df$resp1=rnorm(length(df$fac1))
df
# define a funciton to compute mean, std error and n.
meanstderr <- function(x) c(Mean=mean(x,na.rm=TRUE),se=sqrt(var
(x,na.rm=TRUE)/length(na.omit(x))), n=length(na.omit(x)))
# what I want to wrap into a single funtction:
sumdf=with(df, summarize(X=resp1, by=llist(fac1, fac2, fac3),
stat.name="resp1", FUN=meanstderr))
xYplot(Cbind(resp1, resp...