R: Count unique items in a vector

Had to look this one up, so here it is:

length(unique(x))

Counts the number of distinct items in a vector in R.

One comment

  1. Thanks Matt this was helpful.