I would like to use ggpubr to plot a scatter plot with the regression equation and the R squared. But I get the following error message " Can't find the y elements in the data ".
Here is a reproducible exemple :
x <- c(841.564927857936, 841.564927857936, 841.424690409534, 841.284499691372,
420.782463928968, 420.88768585043, 420.432103842432, 420.572177840048,
420.712345204767, 420.782463928968, 420.747401645497)
y <- c(43692.05, 51561, 34637.8270288285, 36198.5838053982, 36909.925,
30733.6584146036, 32350.3164029975, 31906.371814093, 30367.0638226962,
32410.975, 31970.2108157654)
df <- data.frame(x,y)
ggscatter(df,x, y, add = "reg.line") +
stat_cor(label.x = 3, label.y = 34) +
stat_regline_equation(label.x = 3, label.y = 32)
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.