I have this sample matrix:
X1 X2 X3 X4 1 F F F F 2 C C C C 3 D D D D 4 A# A# A# A
And I\'m trying to use a for loop to get the n
You could use n_distinct (wrapper for length(unique() from dplyr
n_distinct
length(unique(
dplyr
library(dplyr) df1 %>% summarise_each(funs(n_distinct)) %>% unlist()