geom_lm.Rd
A geom to fit a LM model to a short time series
geom_lm(
mapping = NULL,
data = NULL,
stat = "LM",
position = "identity",
show.legend = NA,
na.rm = FALSE,
inherit.aes = TRUE,
warn = TRUE,
n = 10,
nBootSamples = 499,
pValThreshold = 0.05,
...
)
Set of aesthetic mappings created by aes()
. By default inherit.aes = TRUE
, which
assigns the top-level plotting aes()
to the GLS geom.
Input series to be analyzed. If NULL, data is inherited from previous layer or ggplot
call.
Other arguments may be passed to the stat, including fixed aesthetics.
If slope is significantly different from 0 (p < 0.05), then a line of best fit is returned. Otherwise output
is NULL
.
library(ggplot2)
#Generate series
m <- 0.1
x <- 1:10
y <- m*x + rnorm(10, sd = 0.35)
data <- data.frame(x = x,
y = y)
#Plot series with trend
ggplot(data = data) +
geom_line(aes(x = x, y = y)) +
geom_lm(aes(x = x, y = y))
#> Error in loadNamespace(x) : there is no package called ‘arfit’
#> Warning: Computation failed in `stat_lm()`.
#> Caused by error in `linear_ar1$pValue`:
#> ! $ operator is invalid for atomic vectors