Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(huxtable)
- shapiro.batch <- function(tbl) {
- variables <- vector()
- p_values <- vector()
- n = 0
- for (i in 1:ncol(tbl)) {
- if (is.numeric(tbl[[i]])){
- n = n + 1
- x <- shapiro.test(tbl[[i]])
- variables[n] <- colnames(tbl)[i]
- if (x$p.value < 0.05) {
- p_values[n] <- "Not normal"
- }
- else {
- p_values[n] <- "Normal"
- }
- }
- }
- hux(Variable = variables,
- Normality = p_values) %>%
- set_position("left") %>%
- set_bold(row = 1, col = everywhere) %>%
- set_bottom_border(1, everywhere) %>%
- set_bottom_border(final(1), everywhere)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement