unexpected symbol error?

I am trying to run the following code for an accuracy test for my logistic regression model:
conspdata <- conspdata %>%
pred_tr_journ = case_when(is.na(pred_tr_journ) ~ NA_re
pred_tr_journ >= 0.5 ~ 1,
TRUE ~ 0)
But everytime i try to run it i get the message - Error: unexpected symbol in:
" pred_tr_journ = case_when(is.na(pred_tr_journ) ~ NA_re
I copied the code directly from my lecture slides and just changed the variables and data to my own (which are spelled correctly) so i'm not sure what the error could be. Any suggestions?

Looks like you're missing a comma after the first case.

1 Like

Seconding @startz, the “unexpected symbol error” is always about punctuation (I’ve never seen it from something else.) Do some drills with missing commas and quote marks sprinkled in among good stuff and that will help attune the eyeballs to the subtle highlighting clues that the IDE provides.

And keep in mind two phenomena:

It is more likely that the error is on the line above or below than on the line currently receiving attention.

There are no lonely cockroaches, and it may take a few tries to get the other bugs hidden in dark corners.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.