Skip to content

Commit

Permalink
derivatives will now ignore random effect smooths: fixes #168
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinsimpson committed Jul 6, 2022
1 parent 87b688c commit 1c7f4b8
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions R/derivatives.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
#' with `term`? If `TRUE`, `term` can only be a single string to match
#' against.
#'
#' @note `derivatives()` will ignore any random effect smooths it encounters in
#' `object`.
#'
#' @export
#'
#' @importFrom dplyr filter
Expand Down Expand Up @@ -105,12 +108,20 @@
partial_match = FALSE, ...) {
## handle term
smooth_ids <- if (!missing(term)) {
## which smooths match 'term'
sms <- check_user_select_smooths(smooths(object), term,
partial_match = partial_match)
which(sms)
## which smooths match 'term'
sms <- check_user_select_smooths(smooths(object), term,
partial_match = partial_match)
## need to skip random effect smooths
take <- vapply(object$smooth[sms], smooth_type , character(1)) %in%
"Random effect"
sms[take] <- FALSE
which(sms)
} else {
seq_len(n_smooths(object))
s <- seq_len(n_smooths(object))
## need to skip random effect smooths
take <- vapply(object$smooth, smooth_type,
character(1)) %in% "Random effect"
s[!take]
}

## handle type
Expand Down

0 comments on commit 1c7f4b8

Please sign in to comment.