library(mice)
library(ggplot2)
library(data.table)
data(Obesity)
summary(Obesity)
md.pattern(Obesity)
# Missingness per region (Weight)
dataNA <- setDT(Obesity)[, .(nNA = sum(is.na(Weight)),n=.N), by = Cluster]
dataNA[, propNA:=nNA/n]
dataNA
# Density per region (Weight)
Obesity$Cluster <- as.factor(Obesity$Cluster)
ggplot(Obesity, aes(x = Weight, group=Cluster)) +
geom_histogram(aes(color = Cluster,fill= Cluster),
position = "identity", bins = 30) +
facet_grid(Cluster~.)
Run the code above in your browser using DataLab