R/variableType.R

Defines functions variableType

Documented in variableType

#' @title Summary function for original class
#'
#' @description A \code{\link{summaryFunction}} type function, intended to be called from
#' \code{\link{summarize}}, which finds the
#' original class of a variable. This is just the class for all objects but those of class
#' \code{smartNum}.
#'
#' @param v A variable (vector).
#'
#' @param ... Not in use.
#'
#' @return An object of class \code{summaryResult} with the following entries:
#' \code{$feature} ("Variable type"), \code{$result} (the (original) class of
#' \code{v}) and \code{$value} (identical to \code{$result}).
#'
#' @seealso \code{\link{summarize}}
#'
#' @examples
#'  #For standard variables:
#'    varX <- c(rep(c(1,2,3), each=10))
#'    class(varX)
#'    variableType(varX)
#'
#'  #For smartNum variables:
#'    smartX <- dataReporter::smartNum(varX)
#'    class(smartX)
#'    variableType(smartX)
#'
#' @include smartNum.R
#' @export
variableType <- function(v, ...) {
  vClass <- oClass(v)[1]
  summaryResult(list(feature="Variable type", result = vClass, value = vClass))
}

#' @include variableType.R
variableType <- summaryFunction(variableType, "Data class of variable", allClasses())

Try the dataReporter package in your browser

Any scripts or data that you put into this service are public.

dataReporter documentation built on Nov. 11, 2021, 9:06 a.m.