Ok, so I have a configuration dataframe that will specify, how I want to aggregate a few columns in another dataframe.
config frame:
conf <- rbind(
This looks easier to me (after correcting your sinful ways):
dd <- data.frame( c("a1", "a1", "a1"), c("b1", "b1", "b2"), c(1, 2, 3))
names(dd) <- c("a", "b", "cnt")
aggregate(dd$cnt , dd[ as.character(conf[, 1]) ], sum)
#--------
a b x
1 a1 b1 3
2 a1 b2 3
Stealing @Justin's suggestion here's what I ended up doing.
aggregate(as.formula(paste("cnt",
paste(conf[,1], collapse=" + "),
sep=" ~ ")), data=dd, sum)