Skip to contents

Export (dump) lavaan results

Usage

export_lavaan_results(
  lavaan_model_fit,
  path_name = "lavaan_summary.txt",
  preamble = NULL,
  ...
)

Arguments

lavaan_model_fit

Lavaan object. Lavaan object with fitted ESEM model, usually obtained with lavaan::cfa().

path_name

Character vector. Path directing where to save the text file with the results. It must end with the desired file name with the desired text file extension. The default is to save the file in the current directory with file name "lavaan_summary.txt".

preamble

Character vector. Allows the user to add some text before the results report. Useful to identify the analysis, add information about the data etc.

...

parameter = value pairs. Additional modifiers to lavaan::summary() call. See the full list of available modifiers at (lavaan-class).

Value

Message confirming data dump. Saves the data to a text file as a side-effect.

Details

Runs lavaan::summary() on lavaan_model_fit with modifiers std = TRUE and fit.measures = TRUE and dumps the result to a text file. The user has the option to add some text as a preamble before the results description. It is also possible to add more information to the exported results by including more modifiers to the summary call with the ... named values (e.g. rsquare = TRUE to include r-squared measures), see (lavaan-class) for the full list of available modifiers.

The path_name directories must be separated by "\" (even in Windows).

Examples

HS.model <- ' visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9 '
fit <- lavaan::cfa(HS.model, data= lavaan::HolzingerSwineford1939, std.lv = TRUE)

export_lavaan_results(fit)
#> Lavaan summary saved successfully to /tmp/Rtmp0umAX0/file2a821766aa3a/reference/lavaan_summary.txt
# name the analysis with preamble
export_lavaan_results(fit,
path_name = "titled_lavaan_summary.txt",
preamble = "CLASSIC HOLZINGER SWINEFORD CFA MODEL")
#> Lavaan summary saved successfully to /tmp/Rtmp0umAX0/file2a821766aa3a/reference/titled_lavaan_summary.txt
# add r-squared measure to the exported results
export_lavaan_results(fit,
path = "lavaan_summary_rsquared.txt",
rsquare = TRUE)
#> Lavaan summary saved successfully to /tmp/Rtmp0umAX0/file2a821766aa3a/reference/lavaan_summary_rsquared.txt