options(conflicts.policy = "depends.ok")
library(anchorMplus)
library(psych)
library(dplyr)

Say we want to do a CFA on the famous Big Five personality traits in the psych::bfi dataset.

BFI <- psych::bfi

Column Types

Annotate each column with an R data type.

BFI %<>% 
  mutate(across(matches("^[A-Z][1-5]$"), ordered, 1:6)) %>% 
  mutate(across("gender", factor, 1:2, labels = c("M", "F"))) %>% 
  mutate(across("education", ordered, 1:5))

BFI

Ordinal or dichotomous items are designated in Mplus syntax as follows:

mp_cat(BFI) %>% cat


anchorlytics/anchorMplus documentation built on July 28, 2020, 1:15 p.m.