Get Started →
Syntax Errors

Unexpected token

Matches: unexpected '([^']+)' in

WHAT THIS ERROR MEANS

R encountered a character or symbol it didn't expect at that position. This usually means a missing comma, parenthesis, bracket, or operator.

HOW TO FIX IT

1. Check for missing commas between arguments.

2. Count your opening and closing parentheses/brackets.

3. Look for missing operators like + or %>%.

CODE EXAMPLES

BAD — THIS CAUSES THE ERROR
data.frame(x = 1:5 y = 6:10)
GOOD — CORRECT APPROACH
data.frame(x = 1:5, y = 6:10)

Still stuck?

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

Try RChat Free →

RELATED SYNTAX ERRORS