Skip to content
Prev 306735 / 398506 Next

Is there any R function for data normalization?

Hi Rui,

It doesn't really need one...

doit <- function(x) {(x - min(x, na.rm=TRUE))/(max(x,na.rm=TRUE) -
min(x, na.rm=TRUE))}

# use lapply to apply doit() to every column in a data frame
# mtcars is built into R
normed <- as.data.frame(lapply(mtcars, doit))
# very that the range of all is [0, 1]
lapply(normed, range)

Cheers,

Josh
On Tue, Oct 2, 2012 at 2:51 AM, Rui Esteves <ruimaximo at gmail.com> wrote: