Skip to content
Prev 156541 / 398506 Next

frequency table across multiple variables

Hi

Here is an alternative solution which will include count of the NA. It 
may not be "formally" correct, but it seems to work:

 > mapply(function(x) table(factor(ifelse(is.na(x), "NA", x), 
levels=c("NA",1,2,3,4))), m)
   x1 x2 x3
NA  3  4  0
1   5  0  5
2   3  3  5
3   3  5  4
4   3  5  3
 >

Hope this helps

Ivar Herfindal

Philipp Pagel skrev: