xmap_mat | R Documentation |
Return a table applying a function to all combinations of list elements
xmap_mat(.l, .f, ..., .names = TRUE) xmap_arr(.l, .f, ..., .names = TRUE)
.l |
A list of vectors, such as a data frame. The length of .l determines the number of arguments that .f will be called with. List names will be used if present. |
.f |
A function, formula, or vector (not necessarily atomic). If a function, it is used as is. If a formula, e.g.
This syntax allows you to create very compact anonymous functions. If character vector, numeric vector, or list, it is
converted to an extractor function. Character vectors index by
name and numeric vectors index by position; use a list to index
by position and name at different levels. If a component is not
present, the value of |
... |
Additional arguments passed on to |
.names |
A logical indicating whether to give names to the dimensions of
the matrix or array.
If inputs are named, the names are used.
If inputs are unnamed, the elements of the input are used as names.
Defaults to |
A matrix (for xmap_mat()
) or array (for xmap_arr()
) with
dimensions equal to the lengths of each input in .l
.
future_xmap_mat()
and future_xmap_arr()
to run functions in
parallel.
xmap_vec()
to return a vector.
xmap()
for the underlying functions.
xmap_mat(list(1:3, 1:3), ~ ..1 * ..2) fruits <- c(a = "apple", b = "banana", c = "cantaloupe") xmap_mat(list(1:3, fruits), paste) xmap_mat(list(1:3, fruits), paste, .names = FALSE) xmap_arr(list(1:3, 1:3, 1:3), ~ ..1 * ..2 * ..3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.