This file contains hidden or 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("rlang") | |
#' @import rlang | |
`%>%` <- function(x, y) { | |
lhs <- rlang:::captureArg(x) | |
lhs_value <- eval_bare(lhs$expr, lhs$env) | |
This file contains hidden or 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
### Install monad-aware magrittr | |
devtools::dev_mode(TRUE) | |
devtools::install_github("lionel-/magrittr", ref = "monads") | |
### Monadic Infrastructure | |
bind <- function(x, fun, ...) { | |
UseMethod("bind") |
This file contains hidden or 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
set_groups <- function(.d, .cols = NULL) { | |
stopifnot(is.data.frame(.d)) | |
if (is.null(.cols)) { | |
return(group_by_(.d, .dots = list())) | |
} | |
if (is.numeric(.cols)) { | |
.cols <- names(.d)[.cols] | |
} | |
.cols %>% map_call(dplyr::group_by_, .data = .d) |
This file contains hidden or 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
remap <- function(.x, .f, ...) { | |
.f <- lowliner:::as_function(.f) | |
if (inherits(.f, "fseq")) { | |
# Handle magrittr's functional sequences | |
f_env <- environment(.f) | |
f_env$`_function_list` <- map(f_env$`_function_list`, ~ { | |
env <- new.env(parent = environment(.)) | |
environment(.) <- env | |
. |
NewerOlder