
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 is what I did:
>trend<-numeric(nrow(pricedata))
>cbind(pricedata,trend)
>for(i in 2:nrow(pricedata)){
+if (return[i]>0.01) trend[i]=1 else trend[i]=0
+}

and it doesn't change the values in trend, despite the fact that the return column has several rows with values >0.01 -why?

thx!




 		 	   		  
	[[alternative HTML version deleted]]

