Create a function to normalize the values in a numeric vector between 0 and 1.
MediumProblem Statement
Create a function to normalize the values in a numeric vector between 0 and 1.
Sample Input
Vector: c(10, 20, 30, 40, 50)
Sample Output
Normalized: 0 0.25 0.5 0.75 1
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
# Predefined structure
normalize <- function(vector) {
# Your logic here
}
normalized_vector <- normalize(vector)
print(paste("Normalized:", round(normalized_vector, 2)))
Input
Vector: c(10, 20, 30, 40, 50)
Expected Output
Normalized: 0 0.25 0.5 0.75 1