I have a vector of letters:
v <- c("M", "W", "M", "M", "M", "W", "M", "X", "X", "M", "X", "M",
"M", "M", "W")
How can I have R count the letters in the vector?
Like:
M 9
W 3
X 3
You're looking for the table()
function.
> table(v)
v
M W X
9 3 3