powered by
scales a numeric vector
scale_numeric(x, xmin = min(x, na.rm = TRUE), xmax = max(x, na.rm = TRUE))
a numeric vector of the same length as x, with all values between 0 and 1, except for NAs which are unchanged
the numeric vector to scale
the minimum value used for the scaling. all all x < xmin are set to 0
the maximum value used for the scaling. all x > xmax set to 1
x <- c(0.1, 100, -2.5, 20, 78.2, NA) scaled <- scale_numeric(x) all(is.na(scaled) | (scaled >= 0 & scaled <= 1))
Run the code above in your browser using DataLab