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:

  1. numeric variables: often indicated as num for short, there are many different specific numeric types

  2. character variables: often indicated as chr for short, these are text (non-numeric) variables, also known as string variables

  3. factor variables: sometimes indicated as fct for short, these are qualitative variables that take on specific levels (which can be text) from a finite list

  4. import(): flexible command for loading data files, using the `rio`` package

    data <- import("https://learndata.net/binge.Rds", trust = TRUE)
  5. str(): show the variable type for each variable in a dataset

    str(data)
  6. levels(): show the levels of a factor variable

    levels(data$sex_factor)