Hi Karin,

I'm not sure I understand... Is this what you want ?

d$y - mean(d$y)/sd(d$y)

2009/4/15 Karin Lagesen <karin...@ifi.uio.no>

>
> Hi!
>
> First, pardon me if this is a faq. I think I should be using some sort
> of apply, but I am not managing to figure those out.
>
> I have a data frame similar to this:
>
> > d <- data.frame(x = LETTERS[1:5], y = rnorm(5), z = rnorm(5))
> > d
>  x          y          z
> 1 A  0.1605464 -0.2719820
> 2 B -0.9258660  1.2623117
> 3 C -0.3602656  1.5470351
> 4 D  1.2621797  1.2996500
> 5 E  0.6021728  0.5027095
> >
>
> >From this I want to get a new data frame which contains the z scores
> based on the values found in each row. For instance for element [C,y],
> I would like to calculate (-0.3602656 - mean(column y)/stddev(column
> y)).
>
> Thanks!
> --
> Karin Lagesen, Ph.D.
> karin.lage...@medisin.uio.no
> http://folk.uio.no/karinlag
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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