data <- reactive({
#Complete data
var.nonmissing<- sapply(readData(), function(x)sum(!is.na(x)))
# Missing data
var.missing <- sapply(readData(), function(x)sum(is.na(x)))
# Repetitions - used in coloring bars
Category <-c(rep("Missing", length(var.missing)), rep("Complete",
length(var.nonmissing)))
# Used for plotting both missing and diff together
values <- c(var.missing, var.nonmissing)
new.df <- data.frame(variable = names(var.missing), values,Category)
})
output$miss <- renderPlot({
ggplot(data(), aes(variable, values)) + geom_bar(stat = "identity", aes(fill = Category),
position = "stack") +
ggtitle("Missing and Non-Missing Distribution")+
geom_text(aes(label=values),angle = 90,check_overlap = TRUE,colour="blue",fontface = "oblique",family = "Impact",position = position_stack(vjust = 0.5)) +
labs(x = "Variables", y = "Count") +
theme(plot.title = element_text(family = "Helvetica", face = "bold", size = (18)),
legend.title = element_text(colour = "navy", face = "bold.italic", family = "Helvetica"),
legend.text = element_text(face = "italic", colour="navy",family = "Helvetica"),
axis.title = element_text(family = "Helvetica", size = (10), colour = "navy"),
axis.text.x = element_text(family = "Helvetica", colour = "#993333", size = (8),angle = 55, hjust = 1),
axis.text.y = element_text(family = "Helvetica", colour = "#993333", size = (10)))
})