Skip to content

Commit

Permalink
closes #37
Browse files Browse the repository at this point in the history
  • Loading branch information
rempsyc committed Jun 20, 2024
1 parent 6499617 commit 71b738a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: lavaanExtra
Title: Convenience Functions for Package 'lavaan'
Version: 0.2.0.2
Date: 2024-06-19
Version: 0.2.0.3
Date: 2024-06-20
Authors@R:
person("Rémi", "Thériault", , "remi.theriault@mail.mcgill.ca", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-4315-6788"))
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# lavaanExtra 0.2.1
* Incoming ✨

## lavaanExtra 0.2.0.3
* Fix bug in `nice_fit()` that created an error with categorical variables (#37)

## lavaanExtra 0.2.0.2
* Fix bug in `lavaan_defined()` / `lavaan_extract()` (#36)
* Fix bug in `lavaan_defined()` / `lavaan_extract()` that repeated the first cell on all other rows of the first column (#36)

## lavaanExtra 0.2.0.1
* Now skips tests and examples when `DiagrammeRsvg` is not installed
Expand Down
1 change: 1 addition & 0 deletions R/nice_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ nice_fit_internal <- function(fit) {
"rmsea", "rmsea.ci.lower", "rmsea.ci.upper",
"srmr", "aic", "bic"
)
keep <- keep[keep %in% names(x)]
x <- x[keep]
x_srmr <- lavaan::lavResiduals(fit)$summary["usrmr", 1]
x[names(x) == "srmr"] <- x_srmr
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-nice_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,18 @@ test_that("nice_fit error on wronb object class", {
nice_fit(HS.model, model.labels = seq(1, 10))
)
})

test_that("nice_fit test categorical variable", {
dat <- data.frame(z = sample(c(0, 1), 100, replace = TRUE),
x = sample(1:7, 100, replace = TRUE),
y = sample(1:5, 100, replace = TRUE))
mod <- '
y ~ a*x
z ~ b*y + c*x
ind := a*b
'
fit <- sem(mod, dat, ordered = "z")
expect_s3_class(nice_fit(fit), "data.frame")
})


0 comments on commit 71b738a

Please sign in to comment.