[R] Using If loop in R how to extract even and odd ids

2013-07-31 Thread ravi.raghava1
I have 500 ids ; i want to take out even and odd ids separately and store it another data files. How can it be done in R by using *If and for loop* ?? -- View this message in context: http://r.789695.n4.nabble.com/Using-If-loop-in-R-how-to-extract-even-and-odd-ids-tp4672707.html Sent from

Re: [R] Using If loop in R how to extract even and odd ids

2013-07-31 Thread Rui Barradas
it be done in R by using *If and for loop* ?? -- View this message in context: http://r.789695.n4.nabble.com/Using-If-loop-in-R-how-to-extract-even-and-odd-ids-tp4672707.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r

Re: [R] Using If loop in R how to extract even and odd ids

2013-07-31 Thread arun
Hi, May be this helps: set.seed(24) dat1- data.frame(ID=1:500,value=rnorm(500)) res- split(dat1,dat1$ID%%2) A.K. - Original Message - From: ravi.raghava1 ravi.ragh...@classle.co.in To: r-help@r-project.org Cc: Sent: Wednesday, July 31, 2013 3:46 AM Subject: [R] Using If loop in R how

[R] for/if loop in R

2011-07-21 Thread financial engineer
hi, Can someone please help me figure out where I am making a mistake in my for/if loop: I have a data frame (112 rows) called pricedata with 3 columns: date, prices, return. Now, I want to add a 4th column, trend, which can have 2 values 0 or 1. if return1%, trend=1 else trend=0. so, this

Re: [R] for/if loop in R

2011-07-21 Thread Rainer Schuermann
For me, this works: Now, I want to add a 4th column, trend pricedata$trend - 0 which can have 2 values 0 or 1. if return1%, trend=1 else trend=0. pricedata$trend - ifelse( pricedata$return .01, 1, 0 ) Rgds, Rainer On Thursday 21 July 2011 19:39:15 financial engineer wrote: hi, Can

Re: [R] for/if loop in R

2011-07-21 Thread financial engineer
thanks Rainer, it worked! From: rainer.schuerm...@gmx.net To: r-help@r-project.org; fin_e...@hotmail.com Subject: Re: [R] for/if loop in R Date: Fri, 22 Jul 2011 03:23:19 +0200 For me, this works: Now, I want to add a 4th column, trend pricedata$trend - 0 which can have 2 values

Re: [R] breaking a loop in R

2009-07-04 Thread NatsS
://www.nabble.com/breaking-a-loop-in-R-tp21322868p24325853.html Sent from the R help mailing list archive at Nabble.com. __ 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

Re: [R] breaking a loop in R

2009-07-04 Thread Allan Engelhardt
The break command can only break the innermost loop (the b loop in your case). Rewrite the loop control logic. Here is one example end.a - FALSE; for (a in 1:10) { print(a); for (b in 1:20) { if (a 5 b 5 ) { end.a - TRUE; break; # Breaks the b loop } };

[R] breaking a loop in R

2009-01-06 Thread kayj
Hi All, I was wondering if there is anything that breaks a loop in R. For example, For (k in 1:100) For ( i in 1:10){ If ( condition ){ Break the inner loop } } } In the above case, if the program runs the if statement, then I want the inner loop for (i in 1:10) to stop looping and skip

Re: [R] breaking a loop in R

2009-01-06 Thread jim holtman
was wondering if there is anything that breaks a loop in R. For example, For (k in 1:100) For ( i in 1:10){ If ( condition ){ Break the inner loop } } } In the above case, if the program runs the if statement, then I want the inner loop for (i in 1:10) to stop looping and skip the rest

Re: [R] breaking a loop in R

2009-01-06 Thread Stavros Macrakis
? `break` On Tue, Jan 6, 2009 at 7:58 PM, kayj kjaj...@yahoo.com wrote: I was wondering if there is anything that breaks a loop in R [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman