Learn R Programming

teal.slice (version 0.5.1)

variable_types: Get classes of selected columns from dataset

Description

Get classes of selected columns from dataset

Usage

variable_types(data, columns = NULL)

Value

Character vector of classes of columns from provided data.

Arguments

data

(data.frame or DataFrame or matrix) Object in which to determine variable types.

columns

(character) Vector of columns in data for which to get types. Set to NULL to get types of all columns.

Examples

Run this code
# use non-exported function from teal.slice
variable_types <- getFromNamespace("variable_types", "teal.slice")

variable_types(
  data.frame(
    x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"),
    stringsAsFactors = FALSE
  ),
  "x"
)

variable_types(
  data.frame(
    x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"),
    stringsAsFactors = FALSE
  ),
  c("x", "z")
)

variable_types(
  data.frame(
    x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"),
    stringsAsFactors = FALSE
  )
)

Run the code above in your browser using DataLab