R无法打开带有cfa()的文件

R无法打开带有cfa()的文件,r,rstudio,R,Rstudio,正在尝试立即完成验证性因素分析。已读取,但无法克服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 director

正在尝试立即完成验证性因素分析。已读取,但无法克服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)

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

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


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

我不知道到底发生了什么,因为您没有提供要测试的数据,但我怀疑您应该通过删除额外的空白来修复模型语法。据我所知,
lavan
model语法对于那种有趣的东西非常健壮,但这是唯一让我吃惊的东西。事实上,我甚至不认为
lavan
cfa()
的第一个参数可能是一个文件,所以我想知道您是否加载了错误的包?(我只是假设您使用的是
lavan
,因为您使用的模型语法和您链接到的教程都需要它。您显示的代码看起来不错。您是如何读入数据的
df.raw
…它读入了吗?。您是否尝试启动新的R会话。