Functions that apply expressions to input objects and return atomic vectors e.g., numeric (double), integer, character, logical.

vap_dbl: Iterate over input and return double(s)

vap_chr: Iterate over input and return character(s)

vap_lgl: Iterate over input and return logical(s)

vap_int: Iterate over input and return integer(s)

vap_dbl(.data, .f, ...)

vap_chr(.data, .f, ...)

vap_lgl(.data, .f, ...)

vap_int(.data, .f, ...)

Arguments

.data

Input object–numeric, character, list, data frame, etc.–over which elements will be iterated. If matrix or data frame, each column will be treated as an element.

.f

Action to apply to each element of .data. The action can be articulated in one of the four following ways:

  1. supplying a function object (e.g., mean)

  2. defining a function (in-line; e.g., function(x) mean(x))

  3. specifying a formula-like call where '.x' is assumed to be the iterated over element of .data (e.g., ~ mean(.x))

  4. providing a name or position of .data to return (e.g., 1, "varname", etc.)

...

Other values passed to function call.

Value

A double vector

A character vector

A logical vector

An integer vector

See also

lap dap

Other vap: vapc, vapr

Examples

## character vap_chr(letters, ~ paste0(.x, "."))
#> a b c d e f g h i j k l m n o p #> "a." "b." "c." "d." "e." "f." "g." "h." "i." "j." "k." "l." "m." "n." "o." "p." #> q r s t u v w x y z #> "q." "r." "s." "t." "u." "v." "w." "x." "y." "z."
## double vap_dbl(rnorm(4), round, 3)
#> [1] -1.400 0.255 -2.437 -0.006
## logical vap_lgl(letters, ~ .x %in% c("a", "e", "i", "o", "u"))
#> a b c d e f g h i j k l m #> TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE #> n o p q r s t u v w x y z #> FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
## integer vap_int(as.data.frame(replicate(10, sample(1:10))), 8)
#> [1] 9 4 5 8 2 6 7 3 1 10