[R] conditional replacement

Dimitrios Rizopoulos Dimitris.Rizopoulos at med.kuleuven.be
Tue May 23 20:51:49 CEST 2006


you could try something like:

ifelse(df < 30, 30, ifelse(df > 60, 60, df))

I hope it helps.

Best,
Dimitris

---- 
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Sachin J <sachinj.2006 at yahoo.com>:

> 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
> 
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list