Re: [R] Generate sequence of date based on a group ID

2014-10-08 Thread arun
If the `ids` are ordered as shown in the example, perhaps you need tbl <- table(df$id) rep(seq(as.Date("2000-01-01"), length.out=length(tbl), by=1), tbl) [1] "2000-01-01" "2000-01-01" "2000-01-01" "2000-01-01" "2000-01-01" [6] "2000-01-02" "2000-01-02" "2000-01-02" "2000-01-02"

Re: [R] Generate sequence of date based on a group ID

2014-10-08 Thread Adams, Jean
Does this work for you? df$in1 <- 0 df$in1[match(unique(df$id), df$id)] <- 1 df$date <- as.Date("2000-01-01") + cumsum(df$in1) - 1 Jean On Wed, Oct 8, 2014 at 2:57 AM, Kuma Raj wrote: > I want to generate a sequence of date based on a group id(similar IDs > should have same date). The id varia

[R] Generate sequence of date based on a group ID

2014-10-08 Thread Kuma Raj
I want to generate a sequence of date based on a group id(similar IDs should have same date). The id variable contains unequal observations and the length of the data set also varies. How could I create a sequence that starts on specific date (say January 1, 2000 onwards) and continues until the e