Skip to content

Commit 7f4ae03

Browse files
committed
get better error message for ordinal data and path plot
1 parent 368adeb commit 7f4ae03

File tree

2 files changed

+924
-386
lines changed

2 files changed

+924
-386
lines changed

R/sem.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,8 @@ checkLavaanModel <- function(model, availableVars) {
26952695
modelContainer[["plot"]] <- pcont
26962696

26972697
if (length(options[["models"]]) < 2) {
2698-
.semCreatePathPlot(modelContainer[["results"]][["object"]][[1]], NULL, pcont, options, ready)
2698+
fit <- modelContainer[["results"]][["object"]][[1]]
2699+
.semCreatePathPlot(fit, NULL, pcont, options, ready)
26992700
} else {
27002701

27012702
for (i in seq_along(options[["models"]])) {
@@ -2721,8 +2722,12 @@ checkLavaanModel <- function(model, availableVars) {
27212722

27222723
if (!ready || !inherits(fit, "lavaan")) return()
27232724

2724-
if (length(lavaan::lavInspect(fit, "ordered")) > 0) {
2725-
plt$setError(gettext("Model plot not available with ordinal variables"))
2725+
# this fix is temporary until the semPlot package fixes this issue
2726+
if (fit@Options$conditional.x && length(fit@Data@ov.names.x[[1]]) > 0) {
2727+
# jsut create a plot so we can atatch the error to it
2728+
errorPlot <- createJaspPlot(title = modelname, width = 600, height = 400)
2729+
parentContainer[[modelname]] <- errorPlot
2730+
errorPlot$setError(gettext("Model plot not available when there is at least one exogenous covariate and the 'Exogenous covariate(s) fixed' box is checked."))
27262731
return()
27272732
}
27282733

0 commit comments

Comments
 (0)