
Last chance! 50% off unlimited learning
Sale ends in
# NOT RUN {
# Regression example
my.df <-
data.frame(X = c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1),
Y = c( 2.6, 3.1, 2.5, 5.0, 3.6, 4.0, 5.2, 2.8, 3.8))
# We need to check the names of the returned values!
broom::glance(lm(formula = Y ~ X, data = my.df ))
ggplot(my.df, aes(X, Y)) +
geom_point() +
stat_fit_glance(method = "lm",
method.args = list(formula = y ~ x),
aes(label = sprintf('r^2~"="~%.3f~~italic(P)~"="~%.2f',
stat(r.squared), stat(p.value))),
parse = TRUE)
# }
Run the code above in your browser using DataLab