Last active
July 19, 2019 18:58
-
-
Save grayskripko/c94a2ef0c1853205cfe9d4a53f695be2 to your computer and use it in GitHub Desktop.
Rowwise dplyr
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
# when you need to use tidyselect in a mutate function | |
# https://stackoverflow.com/questions/48353331/row-wise-operations-select-helpers-and-the-mutate-function-in-dplyr | |
tbl %>% mutate(a = select(., contains("abc"))) | |
# based on https://rpubs.com/wch/200398 | |
mtcars %>% purrrlyr::by_row(~any(is.na(.)), .collate = "rows", .to = "has_missing") | |
tibble(a=c(1, NA, 3), b=c(NA, 2, NA), c=c(NA, 5, 6)) %>% | |
mutate(pmap_int(., function(...) sum(lift_ld(is.na)(...)))) | |
mtcars %>% split(seq(nrow(.))) %>% map... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment