[R] Utility function to apply a scale object on another data frame

David Winsemius dwinsemius at comcast.net
Sat Jul 16 14:51:07 CEST 2011

On Jul 16, 2011, at 4:08 AM, E- Cognium wrote:

> Hi Everyone,
> I would like to scale a data frame and then using the same scaling
> parameters scale on another data frame. This will be helpful in  
> scaling the
> test dataset based on train dataset's scaling parameters. I couldn't  
> find
> any utility functions that do this. Any suggestions on how to  
> approach this
> problem?
> x = data.frame(a=1:10,b=11:20)
> y = data.frame(a=2:11,b=12:21)
> s <- scale(x)
> ###
> ### would like scale 'y' using the parameters contained in 's'

Just look at s and consult the obvious help page...


David Winsemius, MD
West Hartford, CT

More information about the R-help mailing list