Error in parse: Unexpected input

2,830 views
Skip to first unread message

Luke

unread,
Jul 13, 2016, 5:31:49 AM7/13/16
to lavaan
Hello,

I am trying to run several CFAs with lavaan, but I keep getting the same error appear. I am sure that it is something simple, but I lack the coding knowledge to fully understand the error:

Error in parse(text = x, keep.source = FALSE) : 
  <text>:1:2: unexpected input
1: ~ ‚
       ^

An example of the specified model is as follows:

> Performance <- '
TaskPurpose =~ P2+P5+P7

HigherPurpose =~ P1+P9+P10

Attention =~ A1+A2+A3+A4+A5+A6+A7+A10

Recognition =~ R2+R4+R5+R6+R8+R10

JobRole =~ G4+G5+G6

DevelopmentOpp =~ G1+G2+G7+G8+G9

TaskChallenge =~ CA1+CA3+CA4

CareerGoals =~ CA5+CA6+CA7+CA8+CA9

Grit =~ C1+C2+C3+C4+C5+C6+C9'
> Fit <- cfa(Performance, data = MGData)

Do you have any suggestions as to why this error might keep appearing?

Thanks!

Yves Rosseel

unread,
Jul 16, 2016, 5:32:35 AM7/16/16
to lav...@googlegroups.com
When I copy-pasted your model syntax, I got problems too:

Error in parse(text = x, keep.source = FALSE) :
<text>:1:10: unexpected input
1: ~ P2+P5+P7â

It would seem your syntax contains a few non-visible characters
(typically at the end of the line). I had too remove them, and then
everything ran fine. This is the cleaned-up version:

Performance <- '
TaskPurpose =~ P2+P5+P7
HigherPurpose =~ P1+P9+P10
Attention =~ A1+A2+A3+A4+A5+A6+A7+A10
Recognition =~ R2+R4+R5+R6+R8+R10
JobRole =~ G4+G5+G6
DevelopmentOpp =~ G1+G2+G7+G8+G9
TaskChallenge =~ CA1+CA3+CA4
CareerGoals =~ CA5+CA6+CA7+CA8+CA9
Grit =~ C1+C2+C3+C4+C5+C6+C9'

lavParseModelString(Performance, as.data.frame = TRUE)

Yves.
> --
> You received this message because you are subscribed to the Google
> Groups "lavaan" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to lavaan+un...@googlegroups.com
> <mailto:lavaan+un...@googlegroups.com>.
> To post to this group, send email to lav...@googlegroups.com
> <mailto:lav...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/lavaan.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages