Reputation: 43
Is anyone able to help me with my ggplot please. I have tried multiple ways to remove the na from the plot, including na.rm = TRUE, na.rm = FALSE and placing these in different areas of the code. I have also tried using na.omit but this removes all data in the dataframe, instead of just na.
Birth_Sex_Plot <- ggplot(sarah_data2, aes(x=days_birth_measurement, y=hc_birth, colour= Autism)) +
theme_classic()+ ylab("HC_Birth") + xlab("Days since measurement")
Birth_Sex_Plot + geom_point() + geom_smooth(method = lm, se=FALSE, fullrange = FALSE, na.rm=FALSE)
Any help would be really appreciated. Thank you
Upvotes: 1
Views: 2559
Reputation: 41265
Without knowing your data, this should do the job. You can subset
your data inside the ggplot so that you remove NA
values from your Autism
column. You can use the following code:
library(ggplot2)
Birth_Sex_Plot <- ggplot(data=subset(sarah_data2, !is.na(Autims)), aes(x=days_birth_measurement, y=hc_birth, colour= Autism)) +
theme_classic()+ ylab("HC_Birth") + xlab("Days since measurement")
Birth_Sex_Plot + geom_point() + geom_smooth(method = lm, se=FALSE, fullrange = FALSE)
Upvotes: 2