1

I created an example data set.

example.label <- c("A","A","A","A","A","B","B","B","B","B")
example.value <- c(5, 4, 4, 5, 3, 8, 9, 11, 10, 9)
example.age <- c(30, 40, 50, 60, 70, 30, 40, 50, 60, 70)
example.data <- data.frame(example.label, example.value,example.age)

Which looks like this...

   example.label example.value example.age
1              A             5          30
2              A             4          40
3              A             4          50
4              A             5          60
5              A             3          70
6              B             8          30
7              B             9          40
8              B            11          50
9              B            10          60
10             B             9          70

I then plotted it using the ggplot2 package and added a regression line for two separate populations based on example.label...

ggplot(example.data, aes(x=example.age,y=example.value,color=example.label)) +
  geom_point() +
  geom_smooth(method = lm,fill=NA)

The graph looks like this...Graph

What I then want to do is have the graph display the equation, p value, and r2 of each separate line. How would I be able to accomplish this?

I hope this hasn't been asked before. Thanks.

David
  • 259
  • 1
  • 2
  • 8
  • [This](https://stackoverflow.com/questions/7549694/adding-regression-line-equation-and-r2-on-graph) might be helpful. – Dan Jun 26 '17 at 16:00

0 Answers0