Sorry last count was wrong ... test =data.frame("first"=c("seven","two","five","four"), "second"=c("three","one","three","one"), "third"=c("four","two","three","four"), "fourth"=c("four","one","one","four")) count =data.frame("dobule1"=c("four","two","three","NA"), "double2"=c("NA","one","NA","NA"), "triple"=c("NA","NA","NA","four"))