Skip to content

Commit 2adc976

Browse files
feat: model call
1 parent 6dd61f4 commit 2adc976

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export(ols_coll_diag)
8686
export(ols_correlations)
8787
export(ols_eigen_cindex)
8888
export(ols_fpe)
89+
export(ols_get_call)
8990
export(ols_get_data)
9091
export(ols_get_deviance)
9192
export(ols_get_df)

R/ols-model-info.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,21 @@ ols_get_predictors <- function(model) {
292292
ols_get_response <- function(model) {
293293
model$model[, 1]
294294
}
295+
296+
#' Model function call
297+
#'
298+
#' Returns the model's function call.
299+
#'
300+
#' @param model An object of class \code{lm}.
301+
#'
302+
#' @return Model's function call.
303+
#'
304+
#' @examples
305+
#' model <- lm(mpg ~ wt + cyl + hp + disp + gear + drat, data = mtcars)
306+
#' ols_get_call(model)
307+
#'
308+
#' @export
309+
#'
310+
ols_get_call <- function(model) {
311+
model$call
312+
}

R/utils.R

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,6 @@ ols_get_terms <- function(model) {
9494
attr(model$terms, 'term.label')
9595
}
9696

97-
#ols_get_predictors <- function(model) {
98-
# model$model[, -1]
99-
#}
100-
101-
#ols_get_response <- function(model) {
102-
# model$model[, 1]
103-
#}
104-
105-
ols_get_call <- function(model) {
106-
model$call
107-
}
108-
10997
ols_get_obs <- function(model) {
11098
nrow(model$model)
11199
}

man/ols_get_call.Rd

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-model-info.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,10 @@ test_that("response data is returned", {
131131
got <- head(ols_get_response(model))
132132
expect_equal(want, got)
133133
})
134+
135+
test_that("model call is returned", {
136+
model <- lm(mpg ~ disp + hp + wt, data = mtcars)
137+
want <- as.call(lm(mpg ~ disp + hp + wt, data = mtcars)$call)
138+
got <- ols_get_call(model)
139+
expect_equal(want, got)
140+
})

0 commit comments

Comments
 (0)