ggplot-method | R Documentation |
This function plots a linear model fit using ggplot2. It creates a scatter plot with a regression line, and displays the regression equation along with the R² value.
## S3 method for class 'lmfit'
ggplot(data, mapping = NULL, ..., environment = parent.frame())
data |
Either a numeric vector (to be used as x) or an object containing the data (e.g., a data frame). |
mapping |
Either a numeric vector (to be used as y when data is numeric) or an aesthetic mapping
created with |
... |
Other arguments passed to ggplot2 components. |
environment |
The environment in which to evaluate the plot. Defaults to |
When provided with two numeric vectors, the function treats them as x and y values, respectively, constructs a data frame, and applies a default mapping. Alternatively, if a data frame is provided, an aesthetic mapping (or default mapping) will be used.
A ggplot object.
## Not run:
library(visa)
# Using numeric vectors for x and y:
ggplot.lmfit(1:10, 2:11)
# Using a data frame:
df <- data.frame(x = runif(10, 1, 10), y = runif(10, 2, 11) + 0.5)
ggplot.lmfit(df, aes(x, y))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.