If you only want a count, please try table text <- "ID Age School Grade 1 10 1 98 2 10 2 97 3 10 1 92 4 11 1 90 5 11 1 80 6 11 2 70 7 10 1 80 8 10 1 79 9 11 2 70"
df <- read.table(textConnection(text),header=T) table(df[,2:3]) If you want sort the data, try order. ----- A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Creating-Enumerated-Variables-tp2290262p2290365.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list 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.