[R] question!!!!

Michael Bedward michael.bedward at gmail.com
Wed Aug 4 10:56:14 CEST 2010


Hi

> I made some design matrix X(in linear regression model)
>
> I there any method to normalize X?

You can normalize a matrix column-wise like this:

# m is a matrix
apply(m, 2, function(x) x / max(x) )

Or normalize row-wise like this:
t(apply(m, 1, function(x) x / max(x) ))

I'm sure there are more elegant ways to do it but those work for me.

Michael



More information about the R-help mailing list