Home > Mobile >  How to debug `unexpected end of input` error in R
How to debug `unexpected end of input` error in R

Time:11-29

Happy if this is closed as a duplicate. Riffing off Error: unexpected symbol/input/string constant/numeric constant/SPECIAL in my code, it took me a long time to see a missing close parenthesis that was flagged with the error Error in str2expression(chars) : <text>:2:0: unexpected end of input (chars was the output of a function that took a number x as its argument, and based on sign(x) returned different strings to be parsed). I might have stared at it for hours were I not saved by a closed question on SO: https://stackoverflow.com/a/17135063/8400969. So, what does the error unexpected end of input mean for str2expression and perhaps elsewhere in R?

CodePudding user response:

As elsewhere, this probably indicates a typo/missing punctuation. The parser reached the end of the input, but expected more, likely due to an opening brace, bracket, parenthesis, etc. without a matching close. Likely fix is finding the open parentheses, braces, and brackets (in the input) and making sure each one is closed (in the input).

  • Related