Try this:
library(tidyverse)
aux_sim$date <- as.Date(aux_sim$date, "%d/%m/%Y")
# create columns day, month, year
aux_sim <- aux_sim %>%
arrange(date) %>%
mutate(d= day(date), m=month(date), y=year(date))
# extract first row of each month, year
a <- aux_sim %>%
group_by(m, y) %>%
slice(1)
# extract the last-2 row of each month, year with day<=25
b <- aux_sim %>%
group_by(m, y) %>%
filter(d<=25) %>%
slice(n()-2)
rbind(a, b) %>% arrange(date) %>% select(date, spot.price.Crude.oil)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…