Skip to content
Prev 350888 / 398502 Next

Count

Hi,
On Wed, May 13, 2015 at 5:58 AM, venkadesan venky <venkynov10 at gmail.com> wrote:
Using dput() is easier for everyone else than just pasting your data in.
I'm not at all sure I understand what you're asking, but what about:

testdata <- data.frame(EmpSize = c(1,2,3,1,2), Camp1 = c(1,0,1,0,1),
Camp2 = c(0,0,1,0,0), Camp3 = c(0,1,0,1,0))

aggregate(rowSums(testdata[, -1] == 0), list(testdata$EmpSize), FUN="sum")