Skip to content

Commit

Permalink
fix check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinsimpson committed Feb 3, 2024
1 parent 712f98b commit 01eedac
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
52 changes: 26 additions & 26 deletions R/data-slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,32 @@
#' ds <- data_slice(m, x2 = evenly(x2, n = 50), x1 = mean(x1))
`data_slice.gam` <- function(object, ..., data = NULL,
envir = environment(formula(object))) {
# prep data
odata <- data
data <- data_slice_data(object, data = data)

# deal with ...
##ellipsis::check_dots_unnamed()
exprs <- rlang::enquos(...)
slice_vars <- purrr::map(exprs, rlang::eval_tidy, data = data)

# check now if there are elements of slice_vars that aren't in the model
vars <- model_vars(object)
nms <- names(slice_vars)
if (any(i <- ! nms %in% vars)) {
message("Some specified variable(s) not used in model:\n",
paste(" * ", nms[i], collapse = "\n", sep = ""),
"\n")
}

# typical values, only needed ones that aren't
need_tv <- setdiff(vars, names(slice_vars))
if (length(need_tv) > 0L) {
tv <- typical_values(object, data = odata, envir = envir)
slice_vars <- append(slice_vars, tv[need_tv])
}

expand_grid(!!!{slice_vars})
# prep data
odata <- data
data <- data_slice_data(object, data = data)

# deal with ...
##ellipsis::check_dots_unnamed()
exprs <- rlang::enquos(...)
slice_vars <- purrr::map(exprs, rlang::eval_tidy, data = data)

# check now if there are elements of slice_vars that aren't in the model
vars <- model_vars(object)
nms <- names(slice_vars)
if (any(i <- !nms %in% vars)) {
message("Some specified variable(s) not used in model:\n",
paste(" * ", nms[i], collapse = "\n", sep = ""),
"\n")
}

# typical values, only needed ones that aren't
need_tv <- setdiff(vars, names(slice_vars))
if (length(need_tv) > 0L) {
tv <- typical_values(object, data = odata, envir = envir)
slice_vars <- append(slice_vars, tv[need_tv])
}

expand_grid(!!!{slice_vars})
}

#' @export
Expand Down
4 changes: 3 additions & 1 deletion R/smooth-estimates.R
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
#' @param model a fitted model; currently only [mgcv::gam()] and [mgcv::bam()]
#' models are suported.
#' @param data a data frame of values to evaluate `smooth` at.
#' @param frequentist logical; use the frequentist covariance matrix?
#'
#' @inheritParams eval_smooth
#'
Expand All @@ -265,7 +266,7 @@
#' @importFrom tidyr nest unnest
#' @importFrom mgcv PredictMat
#' @export
`spline_values` <- function(smooth, data, model, unconditional,
`spline_values` <- function(smooth, data, model, unconditional,
overall_uncertainty = TRUE, frequentist = FALSE) {
X <- PredictMat(smooth, data) # prediction matrix
start <- smooth[["first.para"]]
Expand Down Expand Up @@ -339,6 +340,7 @@
#' @param model a fitted model; currently only [mgcv::gam()] and [mgcv::bam()]
#' models are suported.
#' @param data an optional data frame of values to evaluate `smooth` at.
#' @param frequentist logical; use the frequentist covariance matrix?
#'
#' @inheritParams eval_smooth
#'
Expand Down
2 changes: 2 additions & 0 deletions man/spline_values.Rd

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

2 changes: 2 additions & 0 deletions man/spline_values2.Rd

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

0 comments on commit 01eedac

Please sign in to comment.