#----------------------------------------------------------------------------
# Single-Level Data
# Example 1a: Descriptive statistics for missing data
na.descript(airquality)
# Example 1b: Alternative specification using the 'data' argument
na.descript(., data = airquality)
# Example 2: Descriptive statistics for missing data, print results with 3 digits
na.descript(airquality, digits = 3)
# Example 3: Descriptive statistics for missing data with frequency table
na.descript(airquality, table = TRUE)
#----------------------------------------------------------------------------
# Two-Level Data
# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")
# Example 4: escriptive statistics for missing data
na.descript(Demo.twolevel, cluster = "cluster")
#----------------------------------------------------------------------------
# Three-Level Data
# Create arbitrary three-level data
Demo.threelevel <- data.frame(Demo.twolevel, cluster2 = Demo.twolevel$cluster,
cluster3 = rep(1:10, each = 250))
# Example 5: escriptive statistics for missing data
na.descript(Demo.threelevel, cluster = c("cluster3", "cluster2"))
#----------------------------------------------------------------------------
# Write Results
if (FALSE) {
# Example 6a: Write Results into a text file
na.descript(airquality, table = TRUE, write = "NA_Descriptives.txt")
# Example 6b: Write Results into a Excel file
na.descript(airquality, table = TRUE, write = "NA_Descriptives.xlsx")
result <- na.descript(airquality, table = TRUE, output = FALSE)
write.result(result, "NA_Descriptives.xlsx")
}
Run the code above in your browser using DataLab