Skip to content

Instantly share code, notes, and snippets.

@huberflores
Created October 23, 2015 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huberflores/e2e966f69abd6e8be0db to your computer and use it in GitHub Desktop.
Save huberflores/e2e966f69abd6e8be0db to your computer and use it in GitHub Desktop.
Normalization of data in a range using R
# 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