Displaying 1 result from an estimated 1 matches for "pick_on".
Did you mean:
pick_one
2010 Feb 17
1
Replicating output from a function
...id<-c(1,1,1,rep(4:12))
n<-c(10,20,13,22,28,12,12,36,19,12, 15,8)
r<-c(.68,.56,.23,.64,.49,-.04,.49,.33,.58,.18, .6,.21)
mod1<-factor(c(1,2,2, rep(c(1,2,3),3)))
mod2<-c(1,2,15,rep(3,9))
datas<-data.frame(id,n,r,mod1,mod2)
# intermediate level fuction (courtesy of Hadley Wickham):
pick_one <- function(x) {
if (length(x) == 1) return(x)
sample(x, 1)
}
# Function that I want replicated 100 times:
cat_sum1 <- function(meta, mod) {
m <- meta
m$mod <- mod
meta <- ddply(m, .(id), summarize, r = mean(r), n=mean(n), mod =
pick_one(mod))
meta$z <- 0.5*log((1 +...