
Last chance! 50% off unlimited learning
Sale ends in
Normalizes a character vector to a unit vector
normalize(x)
a numeric or integer vector
The normalized vector as a numeric
The (euclidean) norm of a vector
To normalize a vector to a unit vector
# NOT RUN {
normalize(1:2)
## check vector norms:
x <- 1:2
sqrt(sum(x^2)) ## vector norm
sqrt(sum(normalize(x)^2)) ## norm = 1
# }
Run the code above in your browser using DataLab