[R] Changingvalues in data frame

Frank Gerrit Zoellner fzoellne at TechFak.Uni-Bielefeld.DE
Thu Mar 11 12:19:10 CET 2004


Hi!

I have a question concerning data frames and changing particular values in it.

I have set up a data frame containing n rows of observations od dimension m, so in each row there is a vector of size m. Now I want to introduce a cut off to tha data. Therfore I caluclated the mean and variance within each column using apply:

me<-apply(daten[1:72],2,mean)
st<-apply(daten[1:72],2,var)	

Now I want use the mean and the var to form a cut off value, and apply it to each row of the data frame.

I tried the following

cutoff<-function(x){
      if(x>me+2*st){
        x<-me+2*st
      }
    }

cutd<-apply(daten[1:72],1,cutoff)

but I have to supply somehow the column index to me and st.
Any Ideas ?
Thanks,
Frank
-- 
Frank G. Zoellner
AG Angewandte Informatik
Technische Fakult"at
Universit"at Bielefeld
phone: +49(0)521-106-2951
fax:   +49(0)521-106-2992
email: fzoellne at techfak.uni-bielefeld.de




More information about the R-help mailing list