Last active
April 6, 2022 09:33
-
-
Save jvieroe/0eb3a9e61f9fcdde42344a90d1c8c26e to your computer and use it in GitHub Desktop.
row sums with vector input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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