
<div style="display:block;clear:both;" class="rosetta-reliability-start"></div>
<div class="rosetta-reliability-container">

```{r,eval=TRUE, echo=FALSE}

digits <- x$digits;
conf.level <- x$conf.level;
confLevelPct <- paste0(round(100 * conf.level, 2), "%");

oldKableViewOption <- getOption("kableExtra_view_html", NULL);
options(kableExtra_view_html = FALSE);

if (!exists('headingLevel') || !is.numeric(headingLevel) || (length(headingLevel) != 1)) {
  headingLevel <- 0;
}

```

```{r, results='asis', eval=TRUE}
ufs::heading("Reliability analysis",
             idSlug("rosettaReliability"),
             headingLevel=headingLevel);
```

```{r, echo=echoPartial, results='asis', eval=(!is.null(x$scaleStructure)) }

ufs::heading("Scale structure",
             headingLevel = headingLevel+1);

knitr::knit_print(
  x$scaleStructure,
  headingLevel = headingLevel+2
);

```

```{r, echo=echoPartial, results='asis', eval=(!is.null(x$scaleDescriptiveCIs)) }

ufs::heading("Scale descriptives",
             headingLevel = headingLevel+1);

print(x$scaleDescriptiveCIs);

```

```{r, echo=echoPartial, results='asis', eval=(!is.null(x$itemLevelDescriptiveCIs)) }

ufs::heading("Item-level descriptives",
             headingLevel = headingLevel+1);

print(x$itemLevelDescriptiveCIs);

```

```{r, echo=echoPartial, results='asis', eval=(!is.null(x$itemOmitted_correlations)) }

ufs::heading("Correlations of items with scale",
             headingLevel = headingLevel+1);

row.names(x$itemOmitted_correlations) <-
  x$itemLabels[row.names(x$itemOmitted_correlations)];

colNames <-
  names(x$itemOmitted_correlations);
colNames <-
  gsub("itemRest_r.", "Item-rest correlations:<br />", colNames);
colNames <-
  gsub("itemTotal_r.", "Item-total correlations:<br />", colNames);
colNames <-
  gsub("ci.lo", paste0(confLevelPct, " CI lower bound"), colNames);
colNames <-
  gsub("ci.hi", paste0(confLevelPct, " CI upper bound"), colNames);
colNames <-
  gsub("point", "point estimate", colNames);

ufs::kblXtra(
  x$itemOmitted_correlations,
  digits = digits,
  col.names = colNames
);

```


```{r, echo=echoPartial, results='asis', eval=(!is.null(x$itemOmitted_internalConsistency)) }

ufs::heading("Internal consistency estimates with items omitted",
             headingLevel = headingLevel+1);

row.names(x$itemOmitted_internalConsistency) <-
  x$itemLabels[row.names(x$itemOmitted_internalConsistency)];

colNames <-
  names(x$itemOmitted_internalConsistency);
colNames <-
  gsub("alpha.", "Coefficient Alpha:<br />", colNames);
colNames <-
  gsub("ci.lo", paste0(confLevelPct, " CI lower bound"), colNames);
colNames <-
  gsub("ci.hi", paste0(confLevelPct, " CI upper bound"), colNames);
colNames <-
  gsub("omega.point_fromPsych", "Omega (from `psych`):<br />point", colNames);
colNames <-
  gsub("omega.point_fromMBESS", "Omega (from `MBESS`):<br />point", colNames);
colNames <-
  gsub("point", "point estimate", colNames);

ufs::kblXtra(
  x$itemOmitted_internalConsistency,
  digits = digits,
  col.names = colNames
);

```

```{r, echo=echoPartial, results='asis', eval=(!is.null(x$scatterMatrix) && printPlots), fig.width=(.2 + .8*length(x$items)), fig.height=(.2 + .8*length(x$items)), fig.cap="Scatter matrix of all items." }

ufs::heading("Scatter matrix",
             headingLevel = headingLevel+1);

x$scatterMatrix$output$scatterMatrix;

```

```{r echo=FALSE}
if (!is.null(oldKableViewOption)) {
  options(kableExtra_view_html = oldKableViewOption);
}
```

</div>
<div style="display:block;clear:both;" class="rosetta-reliability-end"></div>
