check_lavaan_pattern: Run 'grepl' on lavaan model strings.

View source: R/check-lavaan.R

check_lavaan_patternR Documentation

Run grepl on lavaan model strings.

Description

If the pattern is not found, the function throws an error message (that you have to specify explicitly).

Usage

check_lavaan_pattern(
  state,
  patt,
  not_string_msg = NULL,
  incorrect_msg,
  append = TRUE
)

Arguments

state

state to start from (should be state produced by check_object).

patt

pattern to look for in the lavaan model string that was targeted with check_object.

not_string_msg

if specified, this overrides the automatically generated message in case the targetted object is not a string.

incorrect_msg

feedback message if calling the function specified in func for if the test fails

append

whether or not to append the feedback messages to earlier messages that describe the object.

Examples

## Not run: 

# solution model
mod <- 'a =~ x1 + x2'
# student model

# scts that pass
ex() %>%
  check_object("model") %>%
  check_lavaan_pattern("a")

ex() %>%
  check_object("model") %>%
  check_lavaan_pattern("a\\s+=~\\s+x1")

# scts that fail
ex() %>%
  check_object("model") %>%
  check_lavaan_pattern("x2")

ex() %>%
  check_object("model") %>%
  check_lavaan_pattern("x1\\s\\+\\s+x2")

## End(Not run)


datacamp/testwhat.ext documentation built on Aug. 26, 2022, 4:12 p.m.