squarely | R Documentation |
A special case of widely()
. Used to pre-prepare and
post-tidy functions that take an m x n (m items, n features)
matrix and return an m x m (item x item) matrix, such as a
distance or correlation matrix.
squarely(.f, diag = FALSE, upper = TRUE, ...) squarely_(.f, diag = FALSE, upper = TRUE, ...)
.f |
Function to wrap |
diag |
Whether to include diagonal (i = j) in output |
upper |
Whether to include upper triangle, which may be duplicated |
... |
Extra arguments passed on to |
Returns a function that takes at least four arguments:
tbl |
A table |
item |
Name of column to use as rows in wide matrix |
feature |
Name of column to use as columns in wide matrix |
feature |
Name of column to use as values in wide matrix |
... |
Arguments passed on to inner function |
widely()
, pairwise_count()
,
pairwise_cor()
, pairwise_dist()
library(dplyr) library(gapminder) closest_continent <- gapminder %>% group_by(continent) %>% squarely(dist)(country, year, lifeExp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.