Skip to content

Instantly share code, notes, and snippets.

@jvieroe
Last active April 6, 2022 09:33
Show Gist options
  • Save jvieroe/0eb3a9e61f9fcdde42344a90d1c8c26e to your computer and use it in GitHub Desktop.
Save jvieroe/0eb3a9e61f9fcdde42344a90d1c8c26e to your computer and use it in GitHub Desktop.
row sums with vector input
orange <- c("a", "c", "d")
df <- tibble(a = round(rnorm(mean = .5, sd = .1, n = 10), 0),
b = round(rnorm(mean = .5, sd = .1, n = 10), 0),
c = round(rnorm(mean = .5, sd = .1, n = 10), 0),
d = round(rnorm(mean = .5, sd = .1, n = 10), 0),
e = round(rnorm(mean = .5, sd = .1, n = 10), 0))
df %>%
mutate(count = pmap_dbl(select(., orange), sum))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment