/
get_call.R
63 lines (54 loc) · 1.04 KB
/
get_call.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#' @title Get the model's function call
#' @name get_call
#'
#' @description Returns the model's function call when available.
#'
#' @inheritParams find_random
#'
#' @return A function call.
#'
#' @examplesIf require("lme4", quietly = TRUE)
#' data(mtcars)
#' m <- lm(mpg ~ wt + cyl + vs, data = mtcars)
#' get_call(m)
#'
#' m <- lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris)
#' get_call(m)
#' @export
get_call <- function(x) {
UseMethod("get_call")
}
#' @export
get_call.default <- function(x) {
cl <- .safe(getElement(x, "call"))
# For GAMM4
if (is.null(cl) && "gam" %in% names(x)) {
# Where's the call here?
cl <- .safe(x$gam$formula)
}
cl
}
#' @export
get_call.lm <- function(x) {
x$call
}
#' @export
get_call.glm <- get_call.lm
#' @export
get_call.mvord <- function(x) {
x$rho$mc
}
#' @export
get_call.model_fit <- function(x) {
get_call(x$fit)
}
#' @export
get_call.lmerMod <- function(x) {
x@call
}
#' @export
get_call.merMod <- get_call.lmerMod
#' @export
get_call.stanreg <- function(x) {
x$call
}