0

How could I remove NA responses from using the following code?

bar <- ggplot(newdata)
bar + stat_summary(
  aes(x = preferred.actual.factor, y = lifesatisfaction, fill = gender),
  fun.y = mean,
  geom = "bar",
  position = "dodge"
) + stat_summary(
  aes(x = preferred.actual.factor, y = lifesatisfaction, fill = gender),
  fun.data = mean_cl_normal,
  geom = "errorbar",
  position = position_dodge(width = 0.90),
  width = 0.2
) + labs(x = "Time Mismatch", y = "Life Satsifaction")
markus
  • 25,843
  • 5
  • 39
  • 58
  • Welcome to SO. Please share some data to make your problem [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – markus Dec 03 '18 at 12:29

1 Answers1

0

If you want to remove it from your dataframe, then you could try these options before plotting.

To remove cases with NA in any column:

newdata <- na.omit(newdata)

To remove cases with NA in a specific column:

newdata <- newdata[!is.na(newdata$your_column_name),]
Jaccar
  • 1,720
  • 17
  • 46