Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 13 characters in body
Source Link
Gregor Thomas
  • 147.4k
  • 22
  • 185
  • 320

I found a more simple (to me) answer from this YouTube video which worked really well.

library(ggpubr) ggplot(data,aes(x.plot, y.plot)) +   geom_smooth(method='lm'method = 'lm', se=se = FALSE, formula = y~xy ~ x) +    stat_cor(label.x =30= 30, label.y =130= 130, size =4= 4) +    stat_regline_equation(label.x =30= 30, label.y =150= 150, size =4= 4) 

The label.x and label.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. You can play around with these to fit your graph.

I found a more simple (to me) answer from this YouTube video which worked really well.

library(ggpubr) ggplot(data,aes(x.plot, y.plot)) +   geom_smooth(method='lm', se= FALSE, formula = y~x)+   stat_cor(label.x =30, label.y =130, size =4)+   stat_regline_equation(label.x =30, label.y =150, size =4) 

The label.x and label.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. You can play around with these to fit your graph.

I found a more simple (to me) answer from this YouTube video which worked really well.

library(ggpubr) ggplot(data,aes(x.plot, y.plot)) + geom_smooth(method = 'lm', se = FALSE, formula = y ~ x) +  stat_cor(label.x = 30, label.y = 130, size = 4) +  stat_regline_equation(label.x = 30, label.y = 150, size = 4) 

The label.x and label.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. You can play around with these to fit your graph.

added 4 characters in body
Source Link
tdy
  • 42.1k
  • 42
  • 124
  • 125

I found a more simple (to me) answer from this YouTube video which worked really well.

library(ggpubr) ggplot(data,aes(x.plot, y.plot)) + geom_smooth(method='lm', se= FALSE, formula = y~x)+ stat_cor(label.x =30, label.y =130, size =4)+ stat_regline_equation(label.x =30, label.y =150, size =4) 

The label.xlabel.x and label.ylabel.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. You can play around with these to fit your graph.

I found a more simple (to me) answer from this YouTube video which worked really well.

library(ggpubr) ggplot(data,aes(x.plot, y.plot)) + geom_smooth(method='lm', se= FALSE, formula = y~x)+ stat_cor(label.x =30, label.y =130, size =4)+ stat_regline_equation(label.x =30, label.y =150, size =4) 

The label.x and label.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. You can play around with these to fit your graph.

I found a more simple (to me) answer from this YouTube video which worked really well.

library(ggpubr) ggplot(data,aes(x.plot, y.plot)) + geom_smooth(method='lm', se= FALSE, formula = y~x)+ stat_cor(label.x =30, label.y =130, size =4)+ stat_regline_equation(label.x =30, label.y =150, size =4) 

The label.x and label.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. You can play around with these to fit your graph.

Moved code to codeblock, formatted hyperlink, minor text edits.
Source Link
L Tyrone
  • 8.4k
  • 23
  • 34
  • 47

I found a more simple (to me) answer from this youtube video herethis YouTube video which worked really well.

library(ggpubr)

ggplot(data,aes(x.plot, y.plot)) +

geom_smooth(method='lm', se= FALSE, formula = y~x)+

stat_cor(label.x =30, label.y =130, size =4)+

stat_regline_equation(label.x =30, label.y =150, size =4)

library(ggpubr) ggplot(data,aes(x.plot, y.plot)) + geom_smooth(method='lm', se= FALSE, formula = y~x)+ stat_cor(label.x =30, label.y =130, size =4)+ stat_regline_equation(label.x =30, label.y =150, size =4) 

theThe label.x and label.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. youYou can play around with these to fit your graph.

I found a more simple (to me) answer from this youtube video here which worked really well.

library(ggpubr)

ggplot(data,aes(x.plot, y.plot)) +

geom_smooth(method='lm', se= FALSE, formula = y~x)+

stat_cor(label.x =30, label.y =130, size =4)+

stat_regline_equation(label.x =30, label.y =150, size =4)

the label.x and label.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. you can play around with these to fit your graph

I found a more simple (to me) answer from this YouTube video which worked really well.

library(ggpubr) ggplot(data,aes(x.plot, y.plot)) + geom_smooth(method='lm', se= FALSE, formula = y~x)+ stat_cor(label.x =30, label.y =130, size =4)+ stat_regline_equation(label.x =30, label.y =150, size =4) 

The label.x and label.y just indicate the positions on the x-axis and y-axis where the equation and coefficient should be placed. You can play around with these to fit your graph.

Source Link
Loading