0

I keep getting an error message stating unexpected string constant in R when trying to complete factor analysis. It always seems to be the last two lines of information which are causing the issue. From what I can tell I am not missing any quotation marks which I have learnt is a common error that occurs. Someone previously suggested not using quotation marks at all but I am unsure what to use instead. I have tried to identify basic packages which I need to include to complete the analysis. Is there a possibility that I am missing one?

> Model'Factor_1 =~ Q5 + Q7 + Q8 + Q10 + Q11

> Factor_2 =~ Q9 + Q12 + Q14 + Q15

> Factor_3 =~ Q17 + Q18 + Q19 + Q20 + Q25

> Factor_4 =~ Q22 + Q23 + Q24

> Factor_5 =~ Q27 + Q29 + Q31 + Q32 + Q36'

Error: unexpected string constant in:

"Factor_4 =~ Q22 + Q23 + Q24

Factor_5 =~ Q27 + Q29 + Q31 + Q32 + Q36'"


> Model'Factor_1 =~ Q5 + Q7 + Q8 + Q10 + Q11

> Factor_2 =~ Q9 + Q12 + Q14 + Q15

> Factor_3 =~ Q17 + Q18 + Q19 + Q20 + Q25

> Factor_4 =~ Q22 + Q23 + Q24

> Factor_5 =~ Q27 + Q29 + Q31 + Q32 + Q36

> Fit = cfa(model = Model, data = data, estimator = "ULSMV", ordered = true)

> Summary(Fit, fit = true)'

Error: unexpected string constant in:

"Fit = cfa(model = Model, data = data, estimator = "ULSMV", ordered = true)

Summary(Fit, fit = true)'"
New contributor
Struggling User is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Commented 6 hours ago

1 Answer 1

1

I can't tell if this is the only problem because we don't have your data, but it looks like you hadn't assigned the model code to an object and had some unbalanced quotes. Does this work:

Model <- '
  Factor_1 =~ Q5 + Q7 + Q8 + Q10 + Q11
  Factor_2 =~ Q9 + Q12 + Q14 + Q15
  Factor_3 =~ Q17 + Q18 + Q19 + Q20 + Q25
  Factor_4 =~ Q22 + Q23 + Q24
  Factor_5 =~ Q27 + Q29 + Q31 + Q32 + Q36'

Fit = cfa(model = Model, data = data, estimator = "ULSMV", ordered = true)

summary(Fit, fit = true)
1
  • Hi Dave, I've got it to work now. Thank you Commented 14 hours ago

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.