0

I have been trying to run this code and nothing is working but it did work a while ago. I do not know what I am doing wrong. I also combined a data set and this is the code I put(I do not know which is the issue)

The error I keep getting is on the line of "fit_CFA_groups", and it states

Error in file(file, "r") : cannot open the connection
3.
file(file, "r")
2.
scan(file = file, what = "", sep = ";", strip.white = TRUE, comment.char = "#")
1.
cfa(three_factor_groups, data = df3, group = "country")

This is the code I have put in

library(haven) #packages 
library(dplyr)
library(vctrs)

library(haven)
NewIrishdata <- read_sav("NewIrishdata.sav")


df3 <- bind_rows(Englishdark, NewIrishdata)
df3
library(haven)
require(semTools)
library(semTools)
library(psych)
library(readr)
require(sem)
library(sem)
three_factor_groups <- 
              'General =~ Machiavellianism1 + Machiavellianism2 + Machiavellianism3 + Machiavellianism4 + Machiavellianism5 + Machiavellianism6 + Machiavellianism7 + Machiavellianism8 + Machiavellianism9
 + Narcissism1 + Narcissism2 + Narcissism3 + Narcissism4 + Narcissism5 + Narcissism6 + Narcissism7 + Narcissism8 + Narcissism9 + Psychopathy1 + Psychopathy2 + Psychopathy3 + Psychopathy4 + Psychopathy5 + Psychopathy6 + Psychopathy7 + Psychopathy8 + Psychopathy9'
fit_CFA_groups<-cfa(three_factor_groups, data= df3, group="country")
summary(fit_CFA_groups)

require(semPlot)
library(semPlot)
require(qgraph)
semPaths(fit_CFA_groups, layout='circle',style = "lisrel",what="std", combineGroups = F)
r2evans
  • 141,215
  • 6
  • 77
  • 149
Megan Owen
  • 11
  • 1
  • 1
    Are those datasets in the working directory. The code didn't show how you created the `Englishdark` – akrun Feb 03 '23 at 17:35
  • I put ```#downloading data library(haven) Englishdark <- read_sav("C:/Users/megan/Downloads/Englishdark.sav") View(Englishdark) #view data``` – Megan Owen Feb 03 '23 at 17:40
  • The error suggests that your path may be incorrect. Please use `file.path` – akrun Feb 03 '23 at 17:44
  • Hiya! How exactly would I use file.path(). What would I put in the (). – Megan Owen Feb 03 '23 at 17:51
  • When formatting code in StackOverflow code blocks, the triple-backticks `\`\`\`` must go on their own line with no code before or after them. On the first (entering) code fence, there _may_ be a language-hint such as `lang-r`, but it is not required, and whether or not it is recognized, it is never displayed. This means that any code that is on the same line as the opening backtick-fence is hidden from readers. Next time you ask a question, please just keep them on their own lines, as in `\n\`\`\`\n`. Cheers. – r2evans Feb 03 '23 at 22:03
  • You should almost always use `library`, not `require`. The latter never stops following code when the package is not available, which is almost never what is intended. Refs: https://stackoverflow.com/a/51263513 – r2evans Feb 03 '23 at 22:04

0 Answers0