Sachin, there's another slower but more flexible way than Gabor's solution:
ifelse(x<30,30,ifelse(x>60,60,x)) HTH, Rogerio. ----- Original Message ----- From: "Sachin J" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Tuesday, May 23, 2006 3:40 PM Subject: [R] conditional replacement > Hi > > How can do this in R. > > >df > > 48 > 1 > 35 > 32 > 80 > > If df < 30 then replace it with 30 and else if df > 60 replace it with > 60. I have a large dataset so I cant afford to identify indexes and then > replace. > Desired o/p: > > 48 > 30 > 35 > 32 > 60 > > Thanx in advance. > > Sachin > __________________________________________________ > > > > [[alternative HTML version deleted]] > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
