0

I have a data set in a scatterplot. I want to "overlap" graphs which include some values and not others, but all in the same data set. Essentially, comparing the correlation with n=5, n=8, and n=10. Is there a way to set my regression line for each of these using the same data?

  geom_point(aes(fill = Vaccine), pch = 21, color = 'black', size = 4) +
  scale_fill_manual(values = color_list3) +
  geom_smooth(method='lm', se=F, color="black", size = 0.5) +
  stat_poly_eq(formula = y ~ x, 
               aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")), 
               parse = TRUE) +
  theme_classic() +
  theme(legend.title = element_text(face = "bold", hjust = 0.5),
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "black")) +
  coord_capped_cart(bottom = 'both', left = 'both') +
  labs(x = 'Log antibodies (GTM)', y = 'Vaccine efficacy') 
  • The data is inherited for each `+` step in your code. If you want different data or a different subset you have to include that change in the data argument of the function. That step and the following `+` steps will then work with the new data. – Brian Montgomery Sep 05 '21 at 22:17
  • Welcome to Stack Overflow. If you could give us a [mcve] that would be great ... you could use a built-in data set like `mtcars` to give us the idea of what you want to do. See https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example ... – Ben Bolker Sep 05 '21 at 22:29
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Sep 05 '21 at 22:33

0 Answers0