(если я правильно понимаю) Вы можете использовать ddply:
ff <- data.frame(f1=c("a", "b", "b", "b", "b", "b", "b"), f2=c("p", "p", "p", "q", "q", "q", "q"), f3=c("x","x","x","x","y", "y", "y"), val=c(1:7))
ddply(ff, .(f1), numcolwise(sum))
ddply(ff, .(f2), numcolwise(sum))
ddply(ff, .(f3), numcolwise(sum))