Created
October 20, 2017 12:45
-
-
Save romainfrancois/50a1d17db668c1a7a520b3d30aadabe3 to your computer and use it in GitHub Desktop.
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
library(purrr) | |
library(dplyr) | |
row_count <- function(.x, .f){ | |
.f <- as_mapper(.f) | |
reduce(.x, function(x, y) x + .f(y), .init = 0 ) | |
} | |
data <- tribble( | |
~x, ~y, ~z, | |
1, 2, 3, | |
0, 2, 3, | |
0, 0, 0, | |
4, 5, 5 | |
) | |
data | |
data %>% | |
row_count( ~ . > 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment