Description Usage Arguments Value See Also Examples
Vectorized outer
.
1 |
x |
A |
FUN |
A vectorized function. |
... |
Other arguments passed to the function
supplied to |
Returns a matrix with the vectorized
outer
function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | pooled.sd <- function(x, y) {
n1 <- length(x)
n2 <- length(y)
s1 <- sd(x)
s2 <- sd(y)
sqrt(((n1-1)*s1 + (n2-1)*s2)/((n1-1) + (n2-1)))
}
euc.dist <- function(x,y) sqrt(sum((x - y) ^ 2))
sum2 <- function(x, y) sum(x, y)
v.outer(mtcars, cor)
v.outer(mtcars, pooled.sd)
v.outer(mtcars[, 1:7], euc.dist)
v.outer(mtcars[, 1:7], sum2)
#mtcars as a list
mtcars2 <- lapply(mtcars[, 1:7], "[")
v.outer(mtcars2, cor)
v.outer(mtcars2, cor, method = "spearman")
v.outer(mtcars2, pooled.sd)
print(v.outer(mtcars[, 1:7], pooled.sd), digits = 1)
print(v.outer(mtcars[, 1:7], pooled.sd), digits = NULL)
v.outer(mtcars2, euc.dist)
v.outer(mtcars2, sum2)
wc3 <- function(x, y) sum(sapply(list(x, y), wc, byrow = FALSE))
L1 <- word_list(DATA$state, DATA$person)$cwl
(x <- v.outer(L1, wc3))
diag(x) <- (sapply(L1, length))
x
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.