---
title: "Confirmatory Factor Analysis"
author: "Statsomat.com"
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
  pdf_document:
    latex_engine: xelatex
    toc: true
    toc_depth: 2
bibliography: ["references.bib"]
params:
  data: NA
  filename: NA
  fencoding: NA
  decimal: NA
  enc_guessed: NA
  vars1: NA
  model: NA
  direction: NA
header-includes:
   - \usepackage{xcolor}
   - \setmainfont[BoldFont=FiraSans-Bold, Extension=.otf]{FiraSans-Regular}
   - \usepackage{booktabs}
   - \usepackage{longtable}
   - \usepackage{float}
---


```{r, dev="cairo_pdf", results="asis", echo = FALSE}
# Check model syntax 
msyntax <- TRUE
model <- params$model
modelsplit <- unlist(strsplit(model, split="\n"))
modelsplit <- gsub(" ", "", modelsplit, fixed = TRUE)
modelsplit <- modelsplit[modelsplit != ""]
for (i in 1:length(modelsplit)){
  if (grepl("=~",modelsplit[i])==FALSE && grepl("~~",modelsplit[i])==FALSE && grepl("~1",modelsplit[i])==FALSE &&
      grepl("#",modelsplit[i])==FALSE){
    cat("Error: Only model lines containing following lavaan model syntax operators are allowed: =\\~,\\~\\~,\\~1", fill=TRUE)
    msyntax <- FALSE
    break
  } 
}
```     


```{r child = 'report_kernel.Rmd', eval=msyntax}
```


```{r include=FALSE}
if (exists("eval5")) ref_indic <- eval5 else ref_indic <- FALSE
```
  
  
```{r, results="asis", eval = ref_indic, echo=FALSE}
cat("\n# References", fill=TRUE)
```
 



