R/model_vars.R

Defines functions model_vars.clmm model_vars.coxph model_vars.lme model_vars.lm model_vars.glm model_vars.glmerMod model_vars.lmerMod model_vars.default model_vars

Documented in model_vars

#' A Function to get the variable names from a model object
#'
#' This function allows you to catch the names of variables from a model object
#' @param
#' @keywords model variables


#' @export
model_vars <- function(x, ...){
    UseMethod("model_vars")
}


#' @export
model_vars.default <- function(obj){
    names(attr(obj$terms, "dataClasses"))
}


#' @export
model_vars.lmerMod <- function(obj){
    terms <- attr(obj@frame, "terms")
    attr(terms, "varnames.fixed")
}

#' @export
model_vars.glmerMod <- function(obj){
    terms <- attr(obj@frame, "terms")
    names(attr(terms, "dataClasses"))
}

#' @export
model_vars.glm <- function(obj){
    names(attr(obj$terms, "dataClasses"))
}

#' @export
model_vars.lm <- function(obj){
    names(attr(obj$terms, "dataClasses"))
}


#' @export
model_vars.lme <- function(obj){
    attr(obj$terms, "term.labels")
}

#' @export
model_vars.coxph <- function(obj){
    all.vars(obj$formula)
}

#' @export
model_vars.clmm <- function(obj){
    all.vars(obj$formula)
}
ghowoo/Wu documentation built on June 10, 2022, 3:47 p.m.