Get Started →
Syntax Errors

Unexpected string constant

Matches: unexpected string constant

WHAT THIS ERROR MEANS

R found a string where it wasn't expected, usually because of a missing comma or operator before it.

HOW TO FIX IT

1. Check for missing commas between arguments.

2. Make sure strings are separated by operators or commas.

3. Verify you're not mixing up assignment operators.

CODE EXAMPLES

BAD — THIS CAUSES THE ERROR
c("apple" "banana" "cherry")
GOOD — CORRECT APPROACH
c("apple", "banana", "cherry")

Still stuck?

Paste your code in RChat and the AI will fix this error in context.

Try RChat Free →

RELATED SYNTAX ERRORS