vec_len | R Documentation |
Computes the Euclidean (L2) norm of a vector or the norm across a specified axis of a matrix.
vec_len(vec, axis = 1)
vec |
A numeric vector or matrix. |
axis |
An integer specifying the axis to compute the norm across.
|
A numeric vector containing the Euclidean norms.
vec <- c(3, 4)
vec_len(vec) # Should return 5
mat <- matrix(1:6, nrow = 2, ncol = 3)
vec_len(mat, axis = 1) # Norms of rows
vec_len(mat, axis = 2) # Norms of columns
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.