library(tidyverse)
# data
df <- Titanic %>% as_tibble()
head(df)
#> # A tibble: 6 x 5
#> Class Sex Age Survived n
#> <chr> <chr> <chr> <chr> <dbl>
#> 1 1st Male Child No 0
#> 2 2nd Male Child No 0
#> 3 3rd Male Child No 35
#> 4 Crew Male Child No 0
#> 5 1st Female Child No 0
#> 6 2nd Female Child No 0
How do I create a list of data frames that correspond to only one Class
? In the above example, there are four different classes. So the list will contain four data frames. After that, I want to assign names to the list's elements. The names will be corresponding Class
names.
Please note that I do not want to manually create the list and assign the names.