purrr: How to intersect one list with several nested lists
问题 I have a data.frame containing parties in government. These parties are nested in a list column grouped by period (= each year). I want to compare the overlap between each government and previous governments. library(tidyverse) df <- tibble::tribble( ~period, ~party, ~seats, 1, "A", 2, 1, "B", 3, 1, "C", 3, 2, "A", 2, 2, "C", 3, 3, "C", 4, 3, "E", 1, 3, "F", 3 ) df1 <- df %>% group_by(period) %>% nest() %>% mutate(gov=map(data, "party") %>% map(.,list)) %>% mutate(prev.govs=map(data, "party")