Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Impute missing values in the Ozone and Solar.R columns
- library(dplyr)
- airquality <- airquality %>%
- mutate(
- Ozone = ifelse(is.na(Ozone), median(Ozone, na.rm = TRUE), Ozone),
- Solar.R = ifelse(is.na(Solar.R), mean(Solar.R, na.rm = TRUE), Solar.R)
- )
- # Explanation: Median is less affected by outliers and may be preferable for skewed data like Ozone.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement