try this:

> x <- 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")
>
> # split into groups
> split(x, cumsum(c(TRUE, diff(x$date) > 1)))
$`1`
           date mon wea
1156 2013-03-01 Mrz  dw
1157 2013-03-02 Mrz  dw
1158 2013-03-03 Mrz  dw
1159 2013-03-04 Mrz  dw
1160 2013-03-05 Mrz  dw
1161 2013-03-06 Mrz  dw
1162 2013-03-07 Mrz  dw
1163 2013-03-08 Mrz  dw
1164 2013-03-09 Mrz  dw

$`2`
           date mon wea
1171 2013-03-16 Mrz  dw
1172 2013-03-17 Mrz  dw
1173 2013-03-18 Mrz  dw

$`3`
           date mon wea
1179 2013-03-24 Mrz  dw
1180 2013-03-25 Mrz  dw
1181 2013-03-26 Mrz  dw
1182 2013-03-27 Mrz  dw
1183 2013-03-28 Mrz  dw

$`4`
           date mon wea
1186 2013-03-31 Mrz  dw

>



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Tue, May 20, 2014 at 12:16 PM, Christoph Schlächter <
christoph.schlaechter@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.
>
>

	[[alternative HTML version deleted]]

