Learn R Programming

umx (version 1.9.1)

umx_is_ordered: Test if one or more variables in a dataframe are ordered

Description

Return the names of any ordinal variables in a dataframe

Usage

umx_is_ordered(df, names = FALSE, strict = TRUE, binary.only = FALSE,
  ordinal.only = FALSE, continuous.only = FALSE)

Arguments

df

A data.frame to look in for ordinal variables (if you offer a matrix or vector, it will be upgraded to a dataframe)

names

whether to return the names of ordinal variables, or a binary (T,F) list (default = FALSE)

strict

whether to stop when unordered factors are found (default = TRUE)

binary.only

only count binary factors (2-levels) (default = FALSE)

ordinal.only

only count ordinal factors (3 or more levels) (default = FALSE)

continuous.only

use with names = TRUE to get the names of the continuous variables

Value

- vector of variable names or Booleans

References

- http://www.github.com/tbates/umx

See Also

Other Test: umx_check_OS, umx_check_model, umx_check_names, umx_check_parallel, umx_check, umx_has_CIs, umx_has_been_run, umx_has_means, umx_has_square_brackets, umx_is_MxData, umx_is_MxMatrix, umx_is_MxModel, umx_is_RAM, umx_is_cov, umx_is_endogenous, umx_is_exogenous

Examples

Run this code
# NOT RUN {
tmp = mtcars
tmp$cyl = ordered(mtcars$cyl) # ordered factor
tmp$vs = ordered(mtcars$vs) # binary factor
umx_is_ordered(tmp) # numeric indices
umx_is_ordered(tmp, names = TRUE)
umx_is_ordered(tmp, names = TRUE, binary.only = TRUE)
umx_is_ordered(tmp, names = TRUE, ordinal.only = TRUE)
umx_is_ordered(tmp, names = TRUE, continuous.only = TRUE)
umx_is_ordered(tmp, continuous.only = TRUE)
isContinuous = !umx_is_ordered(tmp)
tmp$gear = factor(mtcars$gear) # unordered factor
# nb: Factors are not necessarily ordered! By default unordered factors cause an message...
# }
# NOT RUN {
tmp$cyl = factor(mtcars$cyl)
umx_is_ordered(tmp, names=TRUE)
# }

Run the code above in your browser using DataLab