Learn R Programming

umx (version 1.9.1)

umx_is_class: Check if variables in a dataframe are in a list of classes.

Description

Checks the class of each column in a dataframe, seeing if they are Returns a vector of TRUE and FALSE, or, if all ==TRUE, a single binary (the default).

Usage

umx_is_class(df, classes, all = TRUE)

Arguments

df

A dataframe to check

classes

vector of valid classes, e.g. numeric

all

Whether to return a single all() Boolean or each column individually.

Value

- Boolean or Boolean vector

References

- https://github.com/tbates/umx, https://tbates.github.io

See Also

- umx_is_numeric

Other Miscellaneous Functions: install.OpenMx, umx_get_options, umx_is_numeric, umx_open_CRAN_page, umx_pad, xmu_twin_check

Examples

Run this code
# NOT RUN {
# Are the variables in mtcars type character?
umx_is_class(mtcars, "character") # FALSE
# They're all numeric data
umx_is_class(mtcars, "numeric") # TRUE
# Show the test-result for each variable in mtcars
umx_is_class(mtcars, "numeric") # TRUE
# Are they _either_ a char OR a num?
umx_is_class(mtcars, c("character", "numeric"))
# Is zygosity a factor (note we don't drop = F to keep as dataframe)
umx_is_class(twinData[,"zygosity", drop=FALSE], classes = "factor")
# }

Run the code above in your browser using DataLab