code_template: Template for the generated R code

View source: R/code_template.R

code_templateR Documentation

Template for the generated R code

Description

Default R code template used by semproducible when generating the code.

Usage

code_template()

Details

The template is a string with R code that contain placeholders in the form of variables like %%NAME%%. The variables are replaced with actual content of the SEM model during code generation.

Placeholder variables:

  • %%FORMULA%% = lavaan formula.

  • %%OBSERVATIONS%% = number of observations of the actual data.

  • %%VARIABLES%% = column names (variable names) of the covariance matrix.

  • %%VALUES%% = actual values of the covariance matrix.

  • %%LAVAAN_CALL%% = lavaan function call.

  • %%COVMAT_VARIABLE%% = variable name of the covariance matrix.

  • %%FIT_VARIABLE%% = variable name of the lavaan object that is created from lavaan.

Value

a character string with the R code template.

Examples

data <- data.frame(x = rnorm(100), y = rnorm(100))

code <- semproducible(data, formula="y ~ x", template = code_template())

# Modify code template
template <- paste(code_template(), "\n# Adds a comment at end")

code <- semproducible(data, formula="y ~ x", template = template)

# Look at the new code
code

peterdalle/semproducible documentation built on April 1, 2022, 8:47 p.m.