dat <- data.frame(x1 = c(1, NA, 2, 5, 3, NA, 5, 2),
x2 = c(4, 2, 5, 1, 5, 3, 4, 5),
x3 = c(NA, 3, 2, 4, 5, 6, NA, 2),
x4 = c(5, 6, 3, NA, NA, 4, 6, NA))
# Descriptive statistics for missing data
na.descript(dat)
# Descriptive statistics for missing data, print results with 3 digits
na.descript(dat, digits = 3)
# Descriptive statistics for missing data, convert value 2 to NA
na.descript(dat, as.na = 2)
# Descriptive statistics for missing data with frequency table
na.descript(dat, table = TRUE)
if (FALSE) {
# Write Results into a Excel file
na.descript(dat, table = TRUE, write = "NA_Descriptives.xlsx")
result <- na.descript(dat, table = TRUE, output = FALSE)
write.result(result, "NA_Descriptives.xlsx")
}
Run the code above in your browser using DataLab