How to Compute the Euclidean Norm in R (Example Code)
In this tutorial you’ll learn how to return the Euclidean Norm of a vector in the R programming language.
Creation of Exemplifying Data
x <- rep(1, 5) # Example vector in R x # Show vector in RStudio console # [1] 1 1 1 1 1 |
x <- rep(1, 5) # Example vector in R x # Show vector in RStudio console # [1] 1 1 1 1 1
Example: Apply norm() Function to Calculate Euclidean Norm
norm(x, type = "2") # Using norm() function # [1] 2.236068 |
norm(x, type = "2") # Using norm() function # [1] 2.236068