0

I don't know how to join the 2 filter statements

I tried to use & and %>% but no success. 12 represents dec and 2 represents feb

stefan
  • 90,330
  • 6
  • 25
  • 51
Nic
  • 1
  • 1
  • 2
    Welcome to SO! It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data and a snippet of your code which others could run. Also: Please do not post an image of code/data/errors [for these reasons](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question/285557#285557). – stefan Dec 26 '22 at 11:26
  • 1
    This said: Try with `... %>% filter(Month %in% c(1, 2, 12))`. – stefan Dec 26 '22 at 11:28
  • 1
    Thank You! It worked. I'm new to SO and unfamiliar with the rules, thanks for letting me know – Nic Dec 26 '22 at 11:53
  • In addition to @stefan 's solution, you can also combine filter conditions with logical operators (`filter(Month %in% 1:2 & Month == 12)`) or - in case of logical AND - separate them with commas: `filter(Month %in% 1:2, Month == 12)`. – I_O Dec 26 '22 at 12:11
  • @I_O that actual code will never yield any results, since `Month` cannot be in 1:2 AND equal to 12. – Wimpel Dec 26 '22 at 14:50

0 Answers0