Skip to content

Instantly share code, notes, and snippets.

@IndrajeetPatil
Last active August 21, 2019 17:03
Show Gist options
  • Save IndrajeetPatil/d55882a09517f17391db71c57beee443 to your computer and use it in GitHub Desktop.
Save IndrajeetPatil/d55882a09517f17391db71c57beee443 to your computer and use it in GitHub Desktop.
library(tidyverse)
iris %>%
tibble::as_tibble(.) %>%
dplyr::mutate(., row_mean = pmap_dbl(list(Sepal.Length, Sepal.Width), mean))
#> # A tibble: 150 x 6
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species row_mean
#> <dbl> <dbl> <dbl> <dbl> <fct> <dbl>
#> 1 5.1 3.5 1.4 0.2 setosa 5.1
#> 2 4.9 3 1.4 0.2 setosa 4.9
#> 3 4.7 3.2 1.3 0.2 setosa 4.7
#> 4 4.6 3.1 1.5 0.2 setosa 4.6
#> 5 5 3.6 1.4 0.2 setosa 5
#> 6 5.4 3.9 1.7 0.4 setosa 5.4
#> 7 4.6 3.4 1.4 0.3 setosa 4.6
#> 8 5 3.4 1.5 0.2 setosa 5
#> 9 4.4 2.9 1.4 0.2 setosa 4.4
#> 10 4.9 3.1 1.5 0.1 setosa 4.9
#> # ... with 140 more rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment