Try something like, ##Untested zz$FC <- ifelse(zz$FC > 2, zz$FC^2, zz$FC)
and see ?ifelse -Erik Iverson Jabez Wilson wrote: > Dear R help, > > I have a data frame column in which I would like to replace some of the > numbers dependent on their value. > > data frame = zz > > AveExpr t P.Value FC > 7.481964 7.323950 1.778503e-04 2.218760 > 7.585783 12.233056 6.679776e-06 2.155867 > 6.953215 6.996525 2.353705e-04 1.685733 > 7.647513 8.099859 9.512639e-05 1.674742 > 7.285446 7.558675 1.463732e-04 1.584071 > 6.405605 3.344031 1.276812e-02 1.541569 > > I would like to replace the values in column 'FC' which are >2 with their > squared value. > If I do this, however, I get a warning but it does the sum correctly. > Warning message: > number of items to replace is not a multiple of replacement length in: zz[, > 4][zz[, 4] > 2] <- zz[, 4]^2 > > Is there a way to do this without the warning? > > > > --------------------------------- > > [[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. ______________________________________________ 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.