Separating data frame into 10-day intervals by ID

I have a data frame that I would like to separate into 10-day intervals organized by ID. When I use the code below it separates it by ID, but its not in 10-day intervals for each element in the list, and its not organized by ID.

How could I break my data into 10-day intervals and group them by ID?

library(lubridate)
date <- rep_len(seq(dmy("26-12-2010"), dmy("20-12-2013"), by = "days"), 500)
ID <- rep(seq(1, 5), 100)

df <- data.frame(date = date,
                 x = runif(length(date), min = 60000, max = 80000),
                 y = runif(length(date), min = 800000, max = 900000),
                 ID)

t <- unique(df$date)[seq(from = 1, 
                    to = length(unique(df$date)),
                    by = 10)]


interval_10 <- lapply(
  1:(length(t)-1),
  function(k) df %>% 
    filter(date == t)
)


from Recent Questions - Stack Overflow https://ift.tt/3djJQy0
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations