I have a tibble with the first column filled with dates. I want to create a smaller tibble with just the rows corresponding with mondays.
I already figured out that I can get the indexes with:
which(wday(df_KBS$Date)==2)
So I thought about looping these indexes over the tibble...but I guess there must be a much easier way.
Example tibble:
library("lubridate")
#create 200 days daterange
posixct.in <- parse_date_time(x = Sys.Date(), orders = "ymd")
posixct.seq <- posixct.in %m+% days(x = seq.int(from = 0, to = 199, by = 1))
#create tibble with date column and random data
df <- tibble(date = posixct.seq,
group = rep(LETTERS[3:4], each = 100),
x = runif(n = 200, min = 10, max = 15),
y = runif(n = 200, min = 100, max = 150))
#find index mondays
which(wday(df$date)==2)