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

Example: Apply norm() Function to Calculate Euclidean Norm

norm(x, type = "2")        # Using norm() function
# [1] 2.236068

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top