Created
October 23, 2015 13:00
-
-
Save huberflores/e2e966f69abd6e8be0db to your computer and use it in GitHub Desktop.
Normalization of data in a range using R
This file contains hidden or 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
# author Huber Flores | |
# Normalizing data to a target range (a, b) | |
#original dataset | |
mydata <- c(26,33,45,77,15,100,66,21,89,55) | |
A = min(mydata) | |
B = max(mydata) | |
#target range | |
a = 1 | |
b = 10 | |
normalized = (a + (mydata - A)*(b-a)) / (B-A) | |
plot(mydata) | |
dev.new() | |
plot(normalized) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment