Debian Codegraph @

R/first_type.R

raw
1 # Determine whether an expression is of the type that needs a first argument.
2 #
3 # @param a non-evaluated expression.
4 # @return logical - TRUE if expr is of "first-argument" type, FALSE otherwise.
5 is_first <- function(expr) {
6 !any(vapply(expr[-1L], identical, logical(1L), quote(.)))
7 }
8
9 # Prepare a magrittr rhs of "first-argument" type.
10 #
11 # @param a an expression which passes `is_first`
12 # @return an expression prepared for functional sequence construction.
13 prepare_first <- function(expr) {
14 as.call(c(expr[[1L]], quote(.), as.list(expr[-1L])))
15 }