[R] help with loop over data frame

Dr Remo Sammassimo remosammassimo at bigpond.com
Mon Feb 19 03:38:25 CET 2007


Dear List,

This may be the fifth time Ive tried to send this to the list so apologies
if there are multiple emails.

I need some help getting started with this problem. I have a data frame
containing a year of daily stock prices in the following format:

Date       Open   High    Low    Close
1/15/2000   10      11      8     10
1/16/2000   12      12     10     11
etc..


I want to create a new data frame which shows only the rows where the column
value "Open" for 'today' is higher than the column value "High" for the
previous day (previous row). How do I loop over each day accessing values
from different rows and columns, as is needed here?

I have tried 'if' statements but none have worked.

Any help appreciated.

Regards,
Alf Sammassimo
Melbourne,Australia



More information about the R-help mailing list