1

I have a box-plot of certain variables. I see the box plots of a number of days on x-axis (Sunday, Monday, Wednesday, Thursday and Friday). I would like to know how to remove two of the box plots from the graph. To be specific, I don't want there to be a box plot of Monday and Wednesday. The code I used was:

ggplot(contents2019, aes(x = days, y = time)) +
  geom_boxplot() +
  xlab("Day") +
  ylab("Time") +
  theme_bw()
M--
  • 25,431
  • 8
  • 61
  • 93
  • Welcome to Stack Overflow! Please provide a [reproducible example in r](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). The link I provided, will tell you how. Moreover, please take the [tour](https://stackoverflow.com/tour) and visit [how to ask](https://stackoverflow.com/help/how-to-ask). Cheers. – M-- Feb 19 '19 at 20:16

1 Answers1

0

You can filter your dataframe beforehand:

library(tidyverse)

contents2019 %>%
  filter(!days %in% c("Monday", "Wednesday")) %>%  
  ggplot(aes(x = days, y = time)) +
  geom_boxplot() +
  xlab("Day") +
  ylab("Time") +
  theme_bw()
M--
  • 25,431
  • 8
  • 61
  • 93
stoa
  • 93
  • 8