Last active
July 10, 2016 18:03
-
-
Save menugget/7516921 to your computer and use it in GitHub Desktop.
[R function] "new.range" - Scale data to a new range. Arguments include the data, the new minimum, and the new maximum values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new.range <- function(x, new.min=0, new.max=1){ | |
ranx <- range(x, na.rm=TRUE) | |
px <- (x-ranx[1])/(ranx[2]-ranx[1]) | |
res <- new.min+((new.max-new.min)*px) | |
res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment