Hi, #if 'dat` is the dataset May be this helps. lst1 <- setNames(split(dat, cumsum(c(TRUE,diff(dat$date)!=1))),LETTERS[1:4]) A.K.
On Tuesday, May 20, 2014 12:17 PM, Christoph Schlächter <christoph.schlaech...@gmail.com> wrote: Dear all, I have a subset of a data frame with 3 columns and a few rows. The columns are “date” [%Y %m %d], “mon” [%b] and “wea” for type of weather with “dw” dry weather “rw” rainy weather. Here it is as a list: structure(list(date = structure(c(15765, 15766, 15767, 15768, 15769, 15770, 15771, 15772, 15773, 15780, 15781, 15782, 15788, 15789, 15790, 15791, 15792, 15795), class = "Date"), mon = c("Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz", "Mrz"), wea = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("dw", "rw"), class = "factor")), .Names = c("date", "mon", "wea"), row.names = c(1156L, 1157L, 1158L, 1159L, 1160L, 1161L, 1162L, 1163L, 1164L, 1171L, 1172L, 1173L, 1179L, 1180L, 1181L, 1182L, 1183L, 1186L), class = "data.frame") I want to get a period of days when it is dry weather and the difference between days should be not more than one day. For this example I need something to get: Maybe as Group: A: 2013-03-01 Mrz dw 2013-03-02 Mrz dw 2013-03-03 Mrz dw 2013-03-04 Mrz dw 2013-03-05 Mrz dw 2013-03-06 Mrz dw 2013-03-07 Mrz dw 2013-03-08 Mrz dw 2013-03-09 Mrz dw B 2013-03-16 Mrz dw 2013-03-17 Mrz dw 2013-03-18 Mrz dw C 2013-03-24 Mrz dw 2013-03-25 Mrz dw 2013-03-26 Mrz dw 2013-03-27 Mrz dw 2013-03-28 Mrz dw D 2013-03-31 Mrz dw How can I achive this. I really have only very few ideas like cast() or melt() or both but i have trouble with the date format. Thanks in advance. <r-help@r-project.org> <r-help@r-project.org> [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.