[R] performing function on data frame

Karin Lagesen karinlag at ifi.uio.no
Thu Apr 16 12:28:50 CEST 2009


David Hajage <dhajage.r at gmail.com> writes:

> Hi Karin,
>
> I'm not sure I understand... Is this what you want ?
>
> d$y - mean(d$y)/sd(d$y)




Yes, and also a bit no.

Each column in my data frame represents one data set. For every
element in this data set I want to know the z value for that
element. I.e: I want to create a new data frame from the old data
frame, where each element in the new data frame is

newDF[i,j] = oldDF[i,j] - mean(d[,j]) / sddev(d[,j])

I could, I think, iterate like this over the data frame, but I keep
thinking that one of the apply functions should be employed...

Karin
-- 
Karin Lagesen, Ph.D.
karin.lagesen at medisin.uio.no
http://folk.uio.no/karinlag




More information about the R-help mailing list