pairwise_product | R Documentation |
Calculates pairwise_products from unique 2-element combinations of vector x. The output vector is the same length and same order as a lower triangle of matrix with rows and columns x.
pairwise_product(x)
x |
numeric vector. |
vector of pairwise_products, of length (l^2-l)/2, where l=length(x).
John L. Darcy
# x <- 1:6
# y_cpp <- pairwise_product(x)
# y_r <- as.dist(outer(x, x, function(x,y){x*y}))
# print("Calculated with R's outer() function:")
# y_r
# print("As a vector:")
# as.vector(y_r)
# print("Calculated with pairwise_product (C++):")
# y_cpp
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.