colpair_map | R Documentation |
colpair_map()
transforms a data frame by applying a function to each pair
of its columns. The result is a correlation data frame (see
correlate
for details).
colpair_map(.data, .f, ..., .diagonal = NA)
.data |
A data frame or data frame extension (e.g. a tibble). |
.f |
A function. |
... |
Additional arguments passed on to the mapped function. |
.diagonal |
Value at which to set the diagonal (defaults to |
A correlation data frame (cor_df
).
## Using `stats::cov` produces a covariance data frame. colpair_map(mtcars, cov) ## Function to get the p-value from a t-test: calc_p_value <- function(vec_a, vec_b) { t.test(vec_a, vec_b)$p.value } colpair_map(mtcars, calc_p_value)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.