I have a list column data frame with some plots, similar to this:
exdata <- diamonds %>%
group_by(cut) %>%
nest %>%
crossing(dummy = 1:3) %>%
mutate(plots = map(.x = data, ~ ggplot(.x, aes(x = x, y = y)) + geom_point()))
Looks like this:
exdata
# A tibble: 15 x 4
cut data dummy plots
<ord> <list> <int> <list>
1 Fair <tibble [1,610 × 9]> 1 <gg>
2 Fair <tibble [1,610 × 9]> 2 <gg>
3 Fair <tibble [1,610 × 9]> 3 <gg>
4 Good <tibble [4,906 × 9]> 1 <gg>
5 Good <tibble [4,906 × 9]> 2 <gg>
6 Good <tibble [4,906 × 9]> 3 <gg>
7 Very Good <tibble [12,082 × 9]> 1 <gg>
8 Very Good <tibble [12,082 × 9]> 2 <gg>
9 Very Good <tibble [12,082 × 9]> 3 <gg>
10 Premium <tibble [13,791 × 9]> 1 <gg>
11 Premium <tibble [13,791 × 9]> 2 <gg>
12 Premium <tibble [13,791 × 9]> 3 <gg>
13 Ideal <tibble [21,551 × 9]> 1 <gg>
14 Ideal <tibble [21,551 × 9]> 2 <gg>
15 Ideal <tibble [21,551 × 9]> 3 <gg>
I would like to plot these in a similar outcome to using facet_grid based on columns of cut and dummy of dummys. The first column would be all the plots for Fair, the second for Good, the third for Very good etc. The rows would be titled '1', '2' and '3' for each value in dummy. A 3 * 5 grid.
I tried the Patchwork package but this does not have a 'direct' way of doing this. Ideally I'd have the column titles clearly labelled with the corresponding cut and then the rows with the corresponding rows.
Note my particular use case prevents me from building a master data frame and wrangling it to use facet grid in the desired manner, I'm really stuck with a list column in a data frame like above.
How can I assemble my list column of plots into a 3*5 grid with clear column and row titles, like with facet_grid?