Assume you have a vector of characters x: > x [1] "a" "b" "a" "d" "d" "c"
I use a function that counts the number of times each string occurs in x: > sapply(unique(x), function(s) {sum(x == s)}) a b d c 2 1 2 1 Is there a more efficient way of doing this? Cheers, /Ali ______________________________________________ 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.