R/as_amartha.R

Defines functions as_amartha.lm as_amartha.numeric as_amartha.data.frame as_amartha

Documented in as_amartha

#' @title As Amartha
#' @description as_amartha is a generic function to generate particular Amartha objects.
#' Currently, there are two kinds of object, num and df to attach data.frame and numeric inherited objects.
#' It is not replace the original class of the object to avoid main functionality.
#' @param x : it can be a vector or data.frame for now
#' @export
as_amartha <- function(x) {
  UseMethod("as_amartha")
}

#' @export
as_amartha.data.frame <- function(x) {
  class(x) <- c(class(x), "Amartha_df")
  return(x)
}

#' @export
as_amartha.numeric <- function(x) {
  class(x) <- c(class(x), "Amartha_num")
  return(x)
}

#' @export
as_amartha.lm <- function(x) {
  class(x) <- c(class(x), "Amartha_linear_model")
  return(x)
}
blakcjack/amarthaPedia documentation built on Oct. 9, 2020, 7:56 a.m.