Dear List,

Thanks to those who helped with my enquiry a few days ago.

I have a another question on loops, in this case I am trying to print out 
the row of a data frame if the previous 3 values (daily values) in col5 are 
in descending order. I have this loop which works, but ask whether this can 
be done differently (without conventional loop) in R:

flag="T"
d= 3 # d represents previous down days
for(i in (d+1): 100)
{
for( j in (i-d):(i-1))
{
if(x[j,5]<x[i,5]){flag="F"}
}
if( flag == "T"){ print(x[i,1])}
flag="T";
}

Any help appreciated,

Regards,
Alf Sammassimo
Melbourne, Australia.

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to