# NOT RUN {
# Generate data for the example
# }
# NOT RUN {
heartfailure2 <- heartfailure
heartfailure2[sample(seq(NROW(heartfailure2)), 20), "platelets"] <- NA
heartfailure2[sample(seq(NROW(heartfailure2)), 5), "smoking"] <- NA
set.seed(123)
heartfailure2$test <- sample(LETTERS[1:15], 299, replace = TRUE)
heartfailure2$test[1:30] <- NA
# Visualization of all numerical variables
plot_bar_category(heartfailure2)
# Select the variable to diagnose
plot_bar_category(heartfailure2, "test", "smoking")
plot_bar_category(heartfailure2, -test, -smoking)
# Visualize the each plots
plot_bar_category(heartfailure2, each = TRUE)
# Not allow typographic argument
plot_bar_category(heartfailure2, typographic = FALSE)
# Using pipes ---------------------------------
library(dplyr)
# Plot of all categorical variables
heartfailure2 %>%
plot_bar_category()
# Visualize just 7 levels of top frequency
heartfailure2 %>%
plot_bar_category(top = 7)
# Visualize only factor, not character
heartfailure2 %>%
plot_bar_category(add_character = FALSE)
# Using groupd_df ------------------------------
heartfailure2 %>%
group_by(death_event) %>%
plot_bar_category(top = 5)
heartfailure2 %>%
group_by(death_event) %>%
plot_bar_category(each = TRUE, top = 5)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab