The “qqline” Function in R
Package: Base R (stats package)
Purpose: To add a line to a quantile-quantile (Q-Q) plot, typically used to compare the distribution of a dataset against a theoretical distribution (e.g. normal distribution).
General Class: Statistical Visualization
Required Argument(s):
None (Arguments are typically supplied indirectly through the qqplot function).
Notable Optional Arguments:
probs: A numeric vector specifying the probabilities for the quantiles at which the line is drawn.
col: changes the color of the line.
Example:
# Example usage
# Generate a random sample from a normal distribution
data <- rnorm(100)
# Create a Q-Q plot using qqnorm
qqnorm(data)
# Add a line to the Q-Q plot using qqline
qqline(data, col = "red")In this corrected example, qqnorm is used to create the Q-Q plot, and then qqline is used to add a red line to the plot, representing the expected quantiles for a normal distribution.