Skip to contents

Allows users to override automatic type detection.

Usage

var_type(x, type = c("continuous", "discrete", "temporal", "ordered"))

Arguments

x

Vector. The variable to annotate

type

Character. One of "continuous", "discrete", "temporal", "ordered"

Value

The vector with type attribute attached

Examples

# Force a numeric year column to be treated as discrete
data <- data.frame(year = 2020:2025, value = rnorm(6))
data$year <- var_type(data$year, "discrete")

# Force a character column to be treated as continuous (rare)
data$score <- var_type(c(1.5, 2.3, 3.1), "continuous")