# \donttest{
# Visualization of all numerical variables
heartfailure2 <- heartfailure[, c("creatinine", "platelets", "sodium", "sex", "smoking")]
plot_normality(heartfailure2)
# Select the variable to plot
plot_normality(heartfailure2, platelets, sodium)
# Change the method of transformation
plot_normality(heartfailure2, platelets, right = "1/x")
# Non typographic elements
plot_normality(heartfailure2, platelets, typographic = FALSE)
# Using dplyr::grouped_df
library(dplyr)
gdata <- group_by(heartfailure2, sex, smoking)
plot_normality(gdata, "creatinine")
# Using pipes ---------------------------------
# Visualization of all numerical variables
heartfailure2 %>%
plot_normality()
# Positive values select variables
# heartfailure2 %>%
# plot_normality(platelets, sodium)
# Using pipes & dplyr -------------------------
# Plot 'creatinine' variable by 'sex' and 'smoking'
heartfailure2 %>%
group_by(sex, smoking) %>%
plot_normality(creatinine)
# extract only those with 'sex' variable level is "Male",
# and plot 'platelets' by 'smoking'
heartfailure2 %>%
filter(sex == "Male") %>%
group_by(smoking) %>%
plot_normality(platelets, right = "sqrt")
# }
Run the code above in your browser using DataLab