library(ggmosaic)
library(tidyverse)
I'm struggling to split a dataset into multiple tables using Tidyverse methods. I'll use the code below to create a dataset with a somewhat similar structure as my actual data.
happy2<-happy%>%
select(sex,marital,degree,health)%>%
group_by(sex,marital,degree,health)%>%
summarise(Count=n())
Now, using the happy2 dataset, I would like to split the data by "degree", and within each category of degree, there will be two tables, one for male and one for female, based on the "sex" variable. Each table will have "marital" and "Count" as the columns and "health" as the rows.
I'm hoping to find an elegant way to create these tables using Tidyverse methods, such as tidyr::nest, purrr, or split.