[R] conditional replacement
Gabor Grothendieck
ggrothendieck at gmail.com
Tue May 23 20:49:04 CEST 2006
x <- 10*1:10
pmin(pmax(x, 30), 60) # 30 30 30 40 50 60 60 60 60 60
On 5/23/06, Sachin J <sachinj.2006 at yahoo.com> wrote:
> 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]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list