Categorical data

Practicing Statistics Interview Questions in R

Zuzanna Chmielewska

Actuary

categorical data

Practicing Statistics Interview Questions in R

nominal categorical data

Practicing Statistics Interview Questions in R

ordinal categorical data

Practicing Statistics Interview Questions in R

example of nominal categorical data

Practicing Statistics Interview Questions in R

example of ordinal categorical data

Practicing Statistics Interview Questions in R

Factors in R

x1 <- c("AB", "A", "O", "AB", "B", "B")

lvls <- c("A", "B", "AB", "O")
x2 <- factor(x1, levels = lvls)
print(x2)
[1] AB A  O  AB B  B 
Levels: A B AB O
Practicing Statistics Interview Questions in R

Factors in R

x1 <- c("M", "L" , "L", "XS", "XL", "S")

lvls <- c("XS", "S", "M", "L", "XL")
x2 <- factor(x1, levels = lvls, ordered = TRUE)
print(x2)
[1] M  L  L  XS XL S 
Levels: XS < S < M < L < XL
Practicing Statistics Interview Questions in R

contingency table in R

Practicing Statistics Interview Questions in R

contingency table in R

Practicing Statistics Interview Questions in R

contingency table in R

Practicing Statistics Interview Questions in R

barplot in R

Practicing Statistics Interview Questions in R

tapply function in R

Practicing Statistics Interview Questions in R

tapply function in R

Practicing Statistics Interview Questions in R

tapply function in R

Practicing Statistics Interview Questions in R
tapply(df$value, df$level, mean)

tapply function in R

Practicing Statistics Interview Questions in R

Categorical data encoding

  • label encoding
  • one hot encoding
  • many more!
Practicing Statistics Interview Questions in R

Label encoding

label encoding

Practicing Statistics Interview Questions in R

Label encoding

label encoding

Practicing Statistics Interview Questions in R

Label encoding

label encoding

Practicing Statistics Interview Questions in R

Label encoding

label encoding

Practicing Statistics Interview Questions in R

Label encoding

label encoding

Practicing Statistics Interview Questions in R

One hot encoding

one hot encoding

Practicing Statistics Interview Questions in R

One hot encoding

one hot encoding

Practicing Statistics Interview Questions in R

One hot encoding

one hot encoding

Practicing Statistics Interview Questions in R

One hot encoding

one hot encoding

Practicing Statistics Interview Questions in R

One hot encoding

one hot encoding

Practicing Statistics Interview Questions in R

Summary

  • types of categorical data
  • factors in R
  • categorical data analysis
    • table()
    • barplot()
    • tapply()
  • data encoding
    • label encoding
    • one hot encoding
Practicing Statistics Interview Questions in R

Let's practice!

Practicing Statistics Interview Questions in R

Preparing Video For Download...