JiaxiangBU / tutoring2

The collection of Python and R code scripts to tutor others.
https://jiaxiangbu.github.io/tutoring2/
Other
8 stars 7 forks source link

map for columns #24

Closed JiaxiangBU closed 4 years ago

JiaxiangBU commented 4 years ago

image

JiaxiangBU commented 4 years ago
library(tidyverse)
df <-
    mtcars %>%
    group_by(cyl) %>%
    nest() %>%
    mutate(x1 = map(data, ~ .$disp))
df
df %>% 
    mutate(if_condition = map2(cyl, x1, ~ .x < .y))

image