Skip to content

Commit

Permalink
more example tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjclark committed Feb 18, 2025
1 parent 5e48e58 commit a2a711b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion R/gratia_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@
#' chains = 2,
#' silent = 2)
#'
#' draw(mod)
#' if(require("gratia")){
#' draw(mod)
#' }
#'
#'}

NULL
Expand Down
13 changes: 10 additions & 3 deletions R/tidier_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,23 @@ augment.mvgam <- function(x,
...) {
obs_data <- x$obs_data
obs_data$.observed <- obs_data$y
obs_data <- purrr::discard_at(obs_data, c("index..orig..order", "index..time..index"))
obs_data <- purrr::discard_at(obs_data,
c("index..orig..order", "index..time..index"))

resids <- residuals(x, robust = robust, probs = probs) %>%
tibble::as_tibble()
fits <- fitted(x, robust = robust, probs = probs) %>%
tibble::as_tibble()
hc_fits <- fits %>%
dplyr::slice_head(n = NROW(resids)) # fits can include fcs
colnames(resids) <- c(".resid", ".resid.variability", ".resid.cred.low", ".resid.cred.high")
colnames(hc_fits) <- c(".fitted", ".fit.variability", ".fit.cred.low", ".fit.cred.high")
colnames(resids) <- c(".resid",
".resid.variability",
".resid.cred.low",
".resid.cred.high")
colnames(hc_fits) <- c(".fitted",
".fit.variability",
".fit.cred.low",
".fit.cred.high")

augmented <- c(obs_data, hc_fits, resids) # coerces to list
if (!identical(class(x$obs_data), "list")) { # data.frame
Expand Down
5 changes: 4 additions & 1 deletion man/gratia_mvgam_enhancements.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a2a711b

Please sign in to comment.