umx_is_ordered | R Documentation |
Return the names of any ordinal variables in a dataframe
umx_is_ordered(
df,
names = FALSE,
strict = TRUE,
binary.only = FALSE,
ordinal.only = FALSE,
continuous.only = FALSE,
summaryObject = FALSE
)
df |
A |
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 other settings (FALSE) |
vector of variable names or Booleans
Other Check or test:
umx
,
umx_check_names()
,
umx_is_class()
,
umx_is_endogenous()
,
umx_is_exogenous()
,
umx_is_numeric()
x = data.frame(ordered(rbinom(100,1,.5))); names(x) = c("x")
umx_is_ordered(x, summaryObject= TRUE) # all ordered factors including binary
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)
x = 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.