I've been playing around with aggregate
and plyr
-- and searched SO -- but can't seem figure this out.
I'm trying to get the mean
for "all other" for a given variable. So, I can use aggregate
to get the mean of var
for each one of the variables in group
-- yes, the variables are characters and have to be escaped :-(
What I'd like to do is get:
- the mean for just
-
, and then separately
- the mean for all other variables (
/ * #
) or not--
combined.
So in the example data below, the mean for -
is 2 and the mean for "all other" is 4.
The real data sets are much longer (1000's of lines), more complex, and variable, so it wouldn't make sense to type the "all other" in separately -- I am thinking something like ~.
would be the way to go.
group var
- 4
- 0
- 2
/ 2
/ 5
* 3
* 7
* 3
# 4
structure(list(group = structure(c(1L, 1L, 1L, 3L, 3L, 2L, 2L,
2L), .Label = c("-", "*", "/"), class = "factor"), var = c(4L,
0L, 2L, 2L, 5L, 3L, 7L, 3L)), .Names = c("group", "var"), class = "data.frame", row.names = c(NA,
-8L))