张志杰 wrote:
> Dear Rusers, I want to standardise the values of x/y coordinates to the unit 
> square, i.e. make the x-values all lie within [0,1] and all the y-values lie 
> within [0,1] in the bottom example.  I had thought to use scale() function to 
> do it, but it seems that it's used to standardise a variable and the scaled 
> value was not within [0,1]. OR, i can divide x/y-values by their maximum 
> value to get it.  I'm not sure about it.#Example data data <- matrix(1:10, 
> nc=2)
> data<-as.data.frame(data)
> names(data)<-c('x','y')> data
>   x  y
> 1 1  6
> 2 2  7
> 3 3  8
> 4 4  9
> 5 5 10  I'd appreciate your help. 
> --

Hi John,
You can do this with the "rescale" function in the plotrix package.

newx<-rescale(x,c(0,1))
newy<-rescale(y,c(0,1))

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to