> x <- c("ABC", "ABC", "ABC", "A02", "ABC", "RCA", "ABC", "ABC")
> table(x)
x
A02 ABC RCA
  1   6   1

> table(x)[c("ABC", "A02", "RCA")]
x
ABC A02 RCA
  6   1   1

On May 29, 2009, at 2:15 PM, liujb wrote:


Dear R users,

Suppose I have a vector that consists of characters like ABC, A02, RCA,
etc., and there are about 700 of possible characters. For example,
x <- c("ABC", "ABC", "ABC", "A02", "ABC", "RCA", "ABC", "ABC")

I'd like to get a frequency matrix that looks something like this:
ABC   6
A02   1
RCA   1

I have like 1M numbers of vectors like x (that can have different length
too). How do I do this?

Thank you very much in advance,

Julia



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
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.

Reply via email to