I would like to return the count of the unique values for every column in a table. For example, if I have the table:
Testdata <- data.frame(var_1 = c(\"a
Here, I've used dplyr and tidyr to count (using your Testdata data frame):
dplyr
tidyr
Testdata
Testdata %>% gather(var, value) %>% distinct() %>% count(var) # # A tibble: 3 × 2 # var n # # 1 var_1 1 # 2 var_2 1 # 3 var_3 3