with str(data) I get the headof the levels (1-2 values)
str(data)
head
fac1: Factor w/ 2 levels ... : fac2: Factor w/ 5 levels ... : fac3: Facto
Or using purrr:
data %>% purrr:map(levels)
Or to first factorize everything:
data %>% dplyr::mutate_all(as.factor) %>% purrr:map(levels)
And answering the question about how to get the lengths:
data %>% map(levels) %>% map(length)