formula.tools (version 1.5.4)

is.cat: Work with variables as categorical or continuous

Description

These functions are used to identify which/if a variable or variables are categorical or continuos. is.cat and is.cont take single variable arguments. which.cat and which.cont take a list or data.frame or any structures whose elements have a class method.

Usage

is.cat(x, ...)
"is.cat"(x)
"is.cat"(x)
"is.cat"(x)
"is.cat"(x)
is.cont(x, ...)
"is.cont"(x)
"is.cont"(x)
"is.cont"(x)
"is.cont"(x)
"is.cont"(x)
"is.cont"(x)
"is.cont"(x)
which.cat(x, ..., names = FALSE)
which.cont(x, ..., names = FALSE)

Arguments

x
object
...
arguments passed to other functions
names
logical; whether to return the names of the variables instead of their index

Value

is.cat returns TRUE if x is character, factor or logical. It is FALSE otherwise.is.cont returns TRUE if x is numeric, integer, complex, Date, POSIXctwhich.cat and which.cont report which variables in an object are categorical and which are continuous. By default, interger indices are return. If names=TRUE, the names of the variables are returned instead.

Details

These functions facilitate working with variables as categorical or continous rather than logical, integer, numeric, factor, character, ..

See Also

which, is

Examples

Run this code
## Not run: 
#   is.cat(letters)          # TRUE
#   is.cat(factor(letters))  # TRUE
#   is.cat(TRUE)             # TRUE
#   is.cat(FALSE)            # TRUE
#   is.cat(1:10)             # FALSE
#   is.cat(rnorm(10))        # FALSE
#   is.cat( now() )          # FALSE
# 
#   is.cont(letters)         # FALSE
#   is.cont(factor(letters)) # FALSE
#   is.cont(TRUE)            # FALSE
#   is.cont(FALSE)           # FALSE
#   is.cont(1:10)            # TRUE
#   is.cont(rnorm(10))      # TRUE
# 
#   which.cat(iris)
#   which.cat( iris, names=TRUE )
# 
#   which.cont( iris )
#   which.cont( iris, names=TRUE )
#  ## End(Not run)

Run the code above in your browser using DataLab