# NOT RUN {
# Normality test of numerical variables
normality(heartfailure)
# Select the variable to describe
normality(heartfailure, platelets, sodium)
normality(heartfailure, -platelets, -sodium)
normality(heartfailure, 1)
normality(heartfailure, platelets, sodium, sample = 200)
# death_eventing dplyr::grouped_dt
library(dplyr)
gdata <- group_by(heartfailure, smoking, death_event)
normality(gdata, "platelets")
normality(gdata, sample = 250)
# death_eventing pipes ---------------------------------
# Normality test of all numerical variables
heartfailure %>%
normality()
# Positive values select variables
heartfailure %>%
normality(platelets, sodium)
# Positions values select variables
heartfailure %>%
normality(1)
# death_eventing pipes & dplyr -------------------------
# Test all numerical variables by 'smoking' and 'death_event',
# and extract only those with 'smoking' variable level is "No".
heartfailure %>%
group_by(smoking, death_event) %>%
normality() %>%
filter(smoking == "No")
# extract only those with 'sex' variable level is "Male",
# and test 'platelets' by 'smoking' and 'death_event'
heartfailure %>%
filter(sex == "Male") %>%
group_by(smoking, death_event) %>%
normality(platelets)
# Test log(platelets) variables by 'smoking' and 'death_event',
# and extract only p.value greater than 0.01.
heartfailure %>%
mutate(platelets_income = log(platelets)) %>%
group_by(smoking, death_event) %>%
normality(platelets_income) %>%
filter(p_value > 0.01)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab