Determine Types of Variables
varType(data, include = NULL, exclude = NULL, ndistinct = 10, nnonnum = 20)
list
of vectors
data frame or table to analyze
formula or vector of variable names to attend to
a formula or character vector specifying which variables to exclude from consideration
minimum number of distinct numeric values a variable must have to be considered continuous
maximum number of distinct values a variable can have to be considered discrete
Frank Harrell
For all the variables in a data frame/table, analyzes them to determine types: continuous, nonnumeric, and discrete. include
and exclude
can be vector or right-side-only formulas.
set.seed(1)
d <- data.frame(i=1:100, x=runif(100), y=sample(1:3, 100, TRUE),
w=sample(c('cat','dog','giraffe'), 100, TRUE),
v=sample(letters, 100, TRUE))
varType(d)
Run the code above in your browser using DataLab