lm_equation: Function to get least-squares regression equation as a...

Description Usage Arguments Author(s) See Also Examples

View source: R/lm_equation.R

Description

lm_equation is used for creating a string which can be plotted with ggplot2.

Usage

1
lm_equation(df, y, x, labels = TRUE, zero_intercept = FALSE, digits = 3)

Arguments

df

Data frame.

y

y-variable.

x

x-variable.

labels

Should the equation show variable names rather than a generic y and x? Default is TRUE.

digits

Number of digits to display for the coefficents in the equation. Default is 3.

Author(s)

Ramnath Vaidyanathan with some enhancement by Stuart K. Grange

See Also

stackoverflow

Examples

1
2
3
4
5
6
7
8
9
## Not run: 

# Use annotation with ggplot
ggplot(data_my1, aes(nox, bc)) + geom_point() + stat_smooth(method = lm) + 
annotate("text", x = 200, y = 45, label = lm_equation(data_my1, "bc", "nox"),
         parse = TRUE)


## End(Not run)

skgrange/enlightenr documentation built on May 30, 2019, 1:03 a.m.