I'm not sure I understand your problem, is this what you mean?
library(dplyr)
library(lubridate)
# Sample data on a copy/paste friendly format
S1 <- data.frame(
stringsAsFactors = FALSE,
Analyte_Name = c("chemx","chemx","chemx",
"chemx","chemx","chemx","chemx","chemx","chemx"),
SampleDate = c("2012-01-09","2012-08-14",
"2013-05-21","2014-09-09","2010-12-28","2013-03-28",
"2010-10-12","2010-03-14","2010-09-16"),
day = c(9L, 14L, 21L, 9L, 28L, 28L, 12L, 14L, 16L),
month = c(1L, 8L, 5L, 9L, 12L, 3L, 10L, 3L, 9L)
)
S1 %>%
filter(SampleDate >= as.Date(paste(year(SampleDate), 03, 15, sep = "-")),
SampleDate <= as.Date(paste(year(SampleDate), 09, 15, sep = "-")))
#> Analyte_Name SampleDate day month
#> 1 chemx 2012-08-14 14 8
#> 2 chemx 2013-05-21 21 5
#> 3 chemx 2014-09-09 9 9
#> 4 chemx 2013-03-28 28 3
Created on 2020-10-03 by the reprex package (v0.3.0)