Re: [R] Rescaling a column in a matrix based on a certain rows

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Fri, 09 May 2008 16:11:37 -0400

Hi Anh,

If I undestarstand:

# Your matrix
set.seed(123)
mat<-matrix(cbind(rnorm(20),rnorm(20)), ncol = 2)

# Scale
(mat-apply(mat[1:5,],2,mean))/apply(mat[1:5,],2,sd)

HTH, Jorge

On Fri, May 9, 2008 at 3:51 PM, Anh Tran <popophobia_at_gmail.com> wrote:

> Hi,
> Let say I have this matrix:
>
> > mat<-matrix(cbind(rnorm(20),rnorm(20)), ncol = 2)
>
> And I want to rescale values of column [,1] and [,2] using values from row
> 1
> to 5, such that the values of row 1:5 should be rescale to the same
> amplitude (kinda like take the z-score of population from row 1:5). column
> 1
> and 2 are two different samples need to be compared.
>
> I hope I made myself clear enough. thanks for any help
>
> UCLA Neurology Research
>
> --
> Regards,
> Anh Tran
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>

        [[alternative HTML version deleted]]



R-help_at_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. Received on Fri 09 May 2008 - 20:40:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 09 May 2008 - 21:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive