Hi, I think you need quotation around I like the following: > status 2010 2011 2012 1 A A A 2 A I I 3 A A A 4 U U U 5 A A A 6 I I I 7 U I I 8 A U A 9 I A U 10 I I I > apply(start,2,function(x) {sum(x=="I",na.rm=TRUE)}) X2010 X2011 X2012 3 4 4
-- View this message in context: http://r.789695.n4.nabble.com/problem-with-conditional-column-sums-tp4702426p4702434.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.