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

Description Usage Arguments Value References See Also Examples

View source: R/misc_and_utility.R

Description

Return the names of any ordinal variables in a dataframe

Usage

1
2
3
4
5
6
7
8
9
umx_is_ordered(
  df,
  names = FALSE,
  strict = TRUE,
  binary.only = FALSE,
  ordinal.only = FALSE,
  continuous.only = FALSE,
  summaryObject = 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

summaryObject

whether to return a nice summary object. Overrides othere settings (FALSE)

Value

References

See Also

Other Check or test: umx_check_names(), umx_is_class(), umx_is_endogenous(), umx_is_exogenous(), umx_is_numeric(), umx

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
tmp = mtcars
tmp$cyl = ordered(mtcars$cyl) # ordered factor
tmp$vs = ordered(mtcars$vs) # binary factor
umx_is_ordered(tmp) # true/false
umx_is_ordered(tmp, strict=FALSE)
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)

umx_is_ordered(tmp, summaryObject= TRUE)

isContinuous = !umx_is_ordered(tmp)
## Not run: 
# nb: By default, unordered factors cause a message...
tmp$gear = factor(mtcars$gear) # Unordered factor
umx_is_ordered(tmp)
umx_is_ordered(tmp, strict = FALSE) # compare: no warning

# also: not designed to work on single variables...
umx_is_ordered(tmp$cyl)
# Do this instead...
umx_is_ordered(tmp[, "cyl", drop=FALSE])

## End(Not run)

tbates/umx documentation built on March 30, 2020, 7:56 a.m.