How to deal with missing values?

There are different ways to deal with missing values. The following examples are based on the missing age in titanic datasets in r.

  • titanic$MissingAge ← is.na(titanic$Age)
  • titanic$MissingAge<- FALSE
  • titanic$MissingAge[is.na(titanic$Age)] ← TRUE
  • titanic$MissingAge ← FALSE
  • titanic[is.na(titanic$Age), “MissingAge”] ← TRUE