R/check_factors.R

Defines functions check_factors

Documented in check_factors

#' Check a dataframe for factors
#'
#' We can use this function to check if your dataframe contains any factors you
#' don't want to use.
#'
#' @param x a dataframe
#'
#' @return vector
#' @export
#'
#' @examples check_factors(iris)
check_factors <- function(x){
  if(!is.data.frame(x)) {
    stop('Please enter a dataframe!\n',
         'You have provided an object of class: ', class(x)[1])}
  names(Filter(is.factor, x))
}
Tangjiahui26/foofactors documentation built on May 18, 2019, 8:11 p.m.