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

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 return>1%, 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, >

[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 return>1%, trend=1 else trend=0. so, this