0

I have a large dataframe "Marks", containing marks each year from 2014/5-2017/8. I have separated the dataframe into 4 smaller ones, by year of completion using:

marks14 <-
Marks%>%
  filter(YearOfCompletion == "2014/5")
marks15 <-
Marks%>%
  filter(YearOfCompletion == "2015/6")
marks16 <-
Marks%>%
  filter(YearOfCompletion == "2016/7")
marks17 <-
Marks%>%
  filter(YearOfCompletion == "2017/8")

I am attempting now to separate the "2016/7" and "2017/8" marks in to one dataframe. I have tried to manipulate the filter function, but I'm unable to figure it out and I can't find the code for this in online cookbooks.

MGMaths
  • 39
  • 3

1 Answers1

1

We can use %in% to filter a vector of dates with length greater than or equal to 1

library(dplyr)
Marks %>%
     filter(YearOfCompletion %in% c("2016/7", "2016/8"))
akrun
  • 874,273
  • 37
  • 540
  • 662