I had a problem like this a couple of months ago. Dennis Murphy helped by suggesting using do(.). It worked then, but when I try to apply it to another problem it's failing.
calc.rel <- function(x, se) {
var.x <- var(x, na.rm=TRUE)
mse <- sum(se^2, na.rm=TRUE)/sum(!is.na(se)) rel <- (var.x - mse)/var.x
data.frame(rel)
}
I have a data frame that looks like this:
head(dm.both)
meas se agency type
1 4.99 1.10 CPS Combined
2 -0.11 0.62 CPS Combined
3 2.29 0.74 CPS Combined
4 3.42 0.78 CPS Combined
5 -1.19 0.59 CPS Combined
6 -0.84 0.59 CPS Combined
I would like to calculate basic statistics and reliability for every combination of agency and type:
dm.comp <- dm.both %>%
group_by(type, agency) %>%
summarize(mean=mean(meas),
stddev=sd(meas),
rel=do(calc.rel(meas, se))
)
But I'm getting this error:
Error in summarize(., mean = mean(meas), stddev = sd(meas), rel = do(calc.rel(meas, : argument "by" is missing, with no default
It works fine without the do(calc.rel()) line.
Any ideas?
--
Stuart Luppescu -- pixbuf .at.
gmail.comI made up a new word: plagiarism.
--jpuller