comb_vars {metan} | R Documentation |
Pairwise combinations of variables
Description
Pairwise combinations of variables that will be the result of a function applied to each combination.
Usage
comb_vars(.data, order = "first", FUN = "+", verbose = TRUE)
Arguments
.data |
A matrix of data with, say, p columns. |
order |
The order on how the results will appear in the output. Default
is |
FUN |
The function that will be applied to each combination. The default
is |
verbose |
Logical argument. If |
Value
A data frame containing all possible combination of variables. Each
combination is the result of the function in FUN
applied to the two
variables.
Author(s)
Tiago Olivoto tiagoolivoto@gmail.com
Examples
library(metan)
data <- data.frame(A = rnorm(n = 5, mean = 10, sd = 3),
B = rnorm(n = 5, mean = 120, sd = 30),
C = rnorm(n = 5, mean = 40, sd = 10),
D = rnorm(n = 5, mean = 1100, sd = 200),
E = rnorm(n = 5, mean = 2, sd = 1))
comb1 <- comb_vars(data)
comb2 <- comb_vars(data, FUN = '*', order = 'second')