Michael,
This will get you started. What you are doing with the seven rows isn't
clear
from your description. I made the dates into "Date" objects. I called your
data
"mydata" as "data" is potentially ambiguous.
Rich
mydata <- read.table(header=TRUE, textConnection("
ds c1 c2
1 2010-04-03 100 0
2 2010-04-30 11141 15
3 2010-05-01 3 16
4 2010-05-02 7615 14
5 2010-05-03 6910 17
6 2010-05-04 5035 3
7 2010-05-05 3007 15
8 2010-05-06 4 14
9 2010-05-07 8335 17
10 2010-05-08 2897 13
11 2010-05-09 6377 17
12 2010-05-10 3177 17
13 2010-05-11 7946 15
14 2010-05-12 8705 0
15 2010-05-13 9030 16
16 2010-05-14 8682 16
17 2010-05-15 8440 15
"))
mydata$ds <- as.Date(mydata$ds)
result <- 0
for (i in seq(length=nrow(mydata)-6)) {
## do something with
mydata[i:(i+6), 2:3]
## and
c(100, 8)
if (TRUE) {
result <- i ## I am returning the start row, not the generic 1.
break
}
}
result
[[alternative HTML version deleted]]
______________________________________________
[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.