R 无法使用 cfa() 打开文件

R cannot open file with cfa()

现在正在尝试完成验证性因素分析。一直在阅读 the tutorial 但无法克服 fit 命令后出现的以下错误:

Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : cannot open file ' independence =~ x1 + x2 + x3 + x4
          therapies =~ x5': No such file or directory

我使用的代码:

df <- data.frame(df.raw)
carl.model <- ' independence =~ x1 + x2 + x3 + x4
                therapies =~ x5 + x6'

fit <- cfa(carl.model, data=df)

summary(fit, fit.measures = TRUE)

重新启动并清理工作区解决了这个问题。我没有对上面的代码做任何更改,现在运行得很干净。

这是因为您有另一个具有相同功能的库。 指定您正在谈论 lavaan

lavaan::cfa(carl.model, data=df)