data_new <- data[data$date > "2021-01-01" & # Extract data frame subset data$date < "2024-01-01", ] data_new # Print new data frame