Mode detection

Mode detection#

To a certain extent, R will auto-detect what mode a variable should have based on the data. There are convenient functions to check a variable’s mode when you need to.

# Auto-detection of variable mode
x <- 1
y <- "word"

mode(x)
mode(y)

# What about if we make a mistake
x <- "1"

is.numeric(x)