错误:代码中意外的符号/输入/字符串常量/数值常数/特殊

错误:代码中意外的符号/输入/字符串常量/数值常数/特殊

我收到了其中一个错误。


Error: unexpected symbol in "<my code>"    

Error: unexpected input in "<my code>"

Error: unexpected string constant in "<my code>"  

Error: unexpected numeric constant in "<my code>"   

Error: unexpected SPECIAL in "<my code>"         

Error: unexpected '<some punctuation>' in "<my code>" 

Error: unexpected '<reserved word>' in "<my code>"        

这个错误意味着什么,我如何修正它?


一些重现错误的简单示例和常见的变体:


a a

## Error: unexpected symbol in "a a"

a\

## Error: unexpected input in "a\"

a""

## Error: unexpected string constant in "a"""

""1

## Error: unexpected numeric constant in """1"

%%

## Error: unexpected SPECIAL in "%%"

,

## Error: unexpected ',' in ","

=

## Error: unexpected '=' in "="

)

## Error: unexpected ')' in ")"

else

## Error: unexpected 'else' in "else"


智慧大石
浏览 8379回答 2
2回答

慕尼黑5688855

对我来说,错误是:Error: unexpected input in "�"修补程序是在十六进制编辑器中打开脚本,并从文件中删除前3个字符。该文件是从一个UTF-8 BOM开始的,而且Rscript似乎无法读取它。编辑:OP请求一个示例。开始吧。➜&nbsp; ~ cat a.Rcat('hello world\n')➜&nbsp; ~ xxd a.R00000000: efbb bf63 6174 2827 6865 6c6c 6f20 776f&nbsp; ...cat('hello wo00000010: 726c 645c 6e27 290a&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rld\n').➜&nbsp; ~ R -f a.R&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;R version 3.4.4 (2018-03-15) -- "Someone to Lean On"Copyright (C) 2018 The R Foundation for Statistical ComputingPlatform: x86_64-pc-linux-gnu (64-bit)R is free software and comes with ABSOLUTELY NO WARRANTY.You are welcome to redistribute it under certain conditions.Type 'license()' or 'licence()' for distribution details.&nbsp; Natural language support but running in an English localeR is a collaborative project with many contributors.Type 'contributors()' for more information and'citation()' on how to cite R or R packages in publications.Type 'demo()' for some demos, 'help()' for on-line help, or'help.start()' for an HTML browser interface to help.Type 'q()' to quit R.> cat('hello world\n')Error: unexpected input in "�"Execution halted
打开App,查看更多内容
随时随地看视频慕课网APP