Variable Types
Model script
install.packages("rio")
library(rio)
data <- import("https://learndata.net/binge.Rds", trust = TRUE)
str(data)
levels(data$sex_factor)Key concepts/syntax:
numeric variables: often indicated as
numfor short, there are many different specific numeric typescharacter variables: often indicated as
chrfor short, these are text (non-numeric) variables, also known as string variablesfactor variables: sometimes indicated as
fctfor short, these are qualitative variables that take on specific levels (which can be text) from a finite listimport(): flexible command for loading data files, using the `rio`` packagedata <- import("https://learndata.net/binge.Rds", trust = TRUE)str(): show the variable type for each variable in a datasetstr(data)levels(): show the levels of a factor variablelevels(data$sex_factor)