Skip to content

Commit efd6a67

Browse files
committed
collect in single file
1 parent 8905de7 commit efd6a67

File tree

5 files changed

+58
-58
lines changed

5 files changed

+58
-58
lines changed

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ Collate:
127127
'facet-grid-.R'
128128
'facet-null.R'
129129
'facet-wrap.R'
130-
'fortify-lm.R'
131130
'fortify-map.R'
132-
'fortify-multcomp.R'
131+
'fortify-models.R'
133132
'fortify-spatial.R'
134133
'fortify.R'
135134
'stat-.R'

R/fortify-lm.R

Lines changed: 0 additions & 54 deletions
This file was deleted.

R/fortify-multcomp.R renamed to R/fortify-models.R

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
1+
#' Supplement the data fitted to a linear model with model fit statistics.
2+
#'
3+
#' @description
4+
#' `r lifecycle::badge("deprecated")`
5+
#'
6+
#' This method is deprecated because using `broom::augment()` is a better
7+
#' solution to supplement data from a linear model.
8+
#' If you have missing values in your model data, you may need to refit
9+
#' the model with `na.action = na.exclude`.
10+
#'
11+
#' @return The original data with extra columns:
12+
#' \item{.hat}{Diagonal of the hat matrix}
13+
#' \item{.sigma}{Estimate of residual standard deviation when
14+
#' corresponding observation is dropped from model}
15+
#' \item{.cooksd}{Cooks distance, [cooks.distance()]}
16+
#' \item{.fitted}{Fitted values of model}
17+
#' \item{.resid}{Residuals}
18+
#' \item{.stdresid}{Standardised residuals}
19+
#' @param model linear model
20+
#' @param data data set, defaults to data used to fit model
21+
#' @param ... not used by this method
22+
#' @keywords internal
23+
#' @export
24+
#' @examplesIf require("broom")
25+
#' mod <- lm(mpg ~ wt, data = mtcars)
26+
#'
27+
#' # Show augmented model
28+
#' head(augment(mod))
29+
#' head(fortify(mod))
30+
#'
31+
#' # Using augment to convert model to ready-to-plot data
32+
#' ggplot(augment(mod), aes(.fitted, .resid)) +
33+
#' geom_point() +
34+
#' geom_hline(yintercept = 0) +
35+
#' geom_smooth(se = FALSE)
36+
#'
37+
#' # Colouring by original data not included in the model
38+
#' ggplot(augment(mod, mtcars), aes(.fitted, .std.resid, colour = factor(cyl))) +
39+
#' geom_point()
40+
fortify.lm <- function(model, data = model$model, ...) {
41+
lifecycle::deprecate_warn(
42+
"3.6.0", I("`fortify(<lm>)`"), I("`broom::augment(<lm>)`")
43+
)
44+
infl <- stats::influence(model, do.coef = FALSE)
45+
data$.hat <- infl$hat
46+
data$.sigma <- infl$sigma
47+
data$.cooksd <- stats::cooks.distance(model, infl)
48+
49+
data$.fitted <- stats::predict(model)
50+
data$.resid <- stats::resid(model)
51+
data$.stdresid <- stats::rstandard(model, infl)
52+
53+
data
54+
}
55+
156
#' Fortify methods for objects produced by \pkg{multcomp}
257
#'
358
#' @description

man/fortify-multcomp.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/fortify.lm.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)