Re: [R] conditional replacement

2006-05-23 Thread Petr Pikal
Date sent: Tue, 23 May 2006 16:34:04 -0300 Subject:Re: [R] conditional replacement > Sachin, > > there's another slower but more flexible way than Gabor's solution: > > ifelse(x<30,30,ifelse(x>60,60,x)) > > HTH, > > Ro

Re: [R] conditional replacement

2006-05-23 Thread Rogerio Porto
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: Sent: Tuesday, May 23, 2006 3:40 PM Subject: [R] conditional re

Re: [R] conditional replacement

2006-05-23 Thread Sachin J
Thank you Gabor,Marc,Dimitrios and Sundar. Sachin Gabor Grothendieck <[EMAIL PROTECTED]> wrote: 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 wrote: > Hi > > How can do this in R. > > >df > > 48 > 1 > 35 > 32 > 80 > > If df < 30 then replace it w

Re: [R] conditional replacement

2006-05-23 Thread Sundar Dorai-Raj
Sachin J 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 t

Re: [R] conditional replacement

2006-05-23 Thread Dimitrios Rizopoulos
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:

Re: [R] conditional replacement

2006-05-23 Thread Marc Schwartz (via MN)
On Tue, 2006-05-23 at 11:40 -0700, Sachin J 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

Re: [R] conditional replacement

2006-05-23 Thread Gabor Grothendieck
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 <[EMAIL PROTECTED]> 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

[R] conditional replacement

2006-05-23 Thread Sachin J
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 3

Re: [R] conditional replacement - readLines

2004-11-27 Thread Uwe Ligges
Christian Schulz wrote: Hi, i have list with 2575 cgi files which i have read with readLines - all Lines have the type "chr". Now i want replace the 2. line with a condition in 4. line and write the files back to dir. How i could avoid the incompatible problem, or is it better doing somethin

[R] conditional replacement - readLines

2004-11-26 Thread Christian Schulz
Hi, i have list with 2575 cgi files which i have read with readLines - all Lines have the type "chr". Now i want replace the 2. line with a condition in 4. line and write the files back to dir. How i could avoid the incompatible problem, or is it better doing something with awk!? for (i in 1