write.result: Write Results of a misty Object into an Excel file

View source: R/write.result.R

write.resultR Documentation

Write Results of a misty Object into an Excel file

Description

This function writes the results of a misty object (misty.object) into a Excel file.

Usage

write.result(x, file = "Results.xlsx", tri = x$args$tri,
             digits = x$args$digits, p.digits = x$args$p.digits,
             icc.digits = x$args$icc.digits, check = TRUE)

Arguments

x

misty object (misty.object) resulting from a misty function supported by the write.result function (see 'Details').

file

a character string naming a file with or without file extension '.xlsx', e.g., "Results.xlsx" or "Results".

tri

a character string or character vector indicating which triangular of the matrix to show on the console, i.e., both for upper and lower triangular, lower for the lower triangular, and upper for the upper triangular.

digits

an integer value indicating the number of decimal places digits to be used for displaying results.

p.digits

an integer indicating the number of decimal places to be used for displaying p-values.

icc.digits

an integer indicating the number of decimal places to be used for displaying intraclass correlation coefficients.

check

logical: if TRUE, argument specification is checked.

Details

Currently the function supports result objects from the function cor.matrix, crosstab, freq, item.alpha, item.cfa, item.invar, item.omega, result.lca, multilevel.cfa, multilevel.cor, multilevel.descript, multilevel.fit, multilevel.invar, multilevel.omega, na.coverage, na.descript, na.pattern, robust.coef, std.coef.

Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at

See Also

cor.matrix, crosstab, freq, item.alpha, item.cfa, item.invar, item.omega, result.lca, multilevel.cfa, multilevel.cor, multilevel.descript, multilevel.fit, multilevel.invar, multilevel.omega, na.coverage, na.descript, na.pattern, robust.coef, std.coef,

Examples

## Not run: 
#--------------------------------------
# cor.matrix() function

result <- cor.matrix(mtcars, print = "all", output = FALSE)
write.result(result, "Correlation.xlsx")

#--------------------------------------
# crosstab() function

result <- crosstab(mtcars[, c("carb", "gear")], print = "all", output = FALSE)
write.result(result, "Crosstab.xlsx")

#--------------------------------------
# descript() function

result <- descript(mtcars, output = FALSE)
write.result(result, "Descript.xlsx")

#--------------------------------------
# freq() function

result <- freq(mtcars, exclude = 99, output = FALSE)
write.result(result, "Freq.xlsx")

#--------------------------------------
# item.alpha() function

result <- item.alpha(attitude, output = FALSE)
write.result(result, "Alpha.xlsx")

#--------------------------------------
# item.cfa() function

# Load data set "HolzingerSwineford1939" in the lavaan package
data("HolzingerSwineford1939", package = "lavaan")

result <- item.cfa(HolzingerSwineford1939[, c("x1", "x2", "x3")],
                   output = FALSE)
write.result(result, "CFA.xlsx")

#--------------------------------------
# item.omega() function

result <- item.omega(attitude, output = FALSE)
write.result(result, "Omega.xlsx")

#--------------------------------------
# multilevel.cor() function

# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")

result <- multilevel.cor(Demo.twolevel[, c("y1", "y2", "y3")],
                         cluster = Demo.twolevel$cluster, output = FALSE)
write.result(result, "Multilevel_Correlation.xlsx")

#--------------------------------------
# multilevel.descript() function

# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")

result <- multilevel.descript(Demo.twolevel[, c("y1", "y2", "y3")],
                              cluster = Demo.twolevel$cluster, output = FALSE)
write.result(result, "Multilevel_Descript.xlsx")

#--------------------------------------
# na.coverage() function

dat <- data.frame(x = c(1, NA, NA, 6, 3),
                  y = c(7, NA, 8, 9, NA),
                  z = c(2, NA, 3, NA, 5))

result <- na.coverage(dat, output = FALSE)
write.result(result, "NA_Coverage.xlsx")

#--------------------------------------
# na.descript() function

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))

 result <- na.descript(dat, table = TRUE, output = FALSE)
write.result(result, "NA_Descriptives.xlsx")

#--------------------------------------
# na.pattern() function

dat <- data.frame(x = c(1, NA, NA, 6, 3),
                  y = c(7, NA, 8, 9, NA),
                  z = c(2, NA, 3, NA, 5))

result <- na.pattern(dat, output = FALSE)
write.result(result, "NA_Pattern.xlsx")

## End(Not run)

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to write.result in misty...