Is there better way to compute this instead of:
length(unique(vector))
let's assume that we donno what class is the vector.
Is there better way to compute this instead of:
length(unique(vector))
let's assume that we donno what class is the vector.
You can use
library(data.table)
vector <- c(1,2,2,2,3)
uniqueN(vector)