'How to list the unique categorical values of a data frame column?

How to list (a list of distinct elements) the unique categorical values of a data frame column?



Solution 1:[1]

ResultingList <- as.list(unique(df$ColumnName))

Solution 2:[2]

Or with purrr:

library(dplyr)
iris %>%
  select_if(is.factor) %>% 
  purrr::map(unique)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Olivier Grimard
Solution 2 Julian