search for: vydv

Displaying 1 result from an estimated 1 matches for "vydv".

Did you mean: vdv
2011 Sep 03
2
problem in applying function in data subset (with a level) - using plyr or other alternative are also welcome
...<- as.vector(x) ot1 <- ifelse(mydf[x[1]] == mydf[x[3]], 1, -1) ot2 <- ifelse(mydf[x[2]] == mydf[x[4]], 1, -1) qt <- ot1 + ot2 return(qt) } qt <- apply(mmat, 1, myfun) ydv <- c((y - mean(y))^2) qtd <- data.frame(ped, ydv, qt) # second function myfun2 <- function(dataframe) { vydv <- sum(ydv)*0.25 sumD <- sum(ydv * qt) Rt <- vydv / sumD return(Rt) } # using plyr require(plyr) dfsumd1 <- ddply(mydf,.(mydf$ped),myfun2) Here are 2 issues: (1) The output just one, I need the output for all three set of variables (as listed above) (2) all three values of dfsumd is...