data(mtcars)
mtcars <- rownames_to_column(mtcars,var = "car")
mtcars$id <- c(1:length(mtcars$car))
mtcars$make <- map_chr(mtcars$car,~strsplit(.x," ")[[1]][1])
mt2 <- mtcars %>% select(1:4,id,make) %>% nest(-make,.key = "l")
mt3 <- mtcars %>% select(5:10,id,make) %>% nest(-make,.key="m")
mt_make <- left_join(mt2,mt3)
mt2 <- mtcars %>% select(1:4,id,make) %>% nest(-id,.key = "l")
mt3 <- mtcars %>% select(5:10,id) %>% nest(-id,.key="m")
mt_id <- left_join(mt2,mt3)
如何过滤mt_make
以仅保留具有6 个气缸和超过150 hp的汽车,并在没有 listcols 的情况下将其嵌套到数据框中?
如何过滤mt_id
以仅保留低于200 hp的Merc并在没有 listcols 的情况下不嵌套到数据框中?