为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

智慧大石 2019-07-06 17:53:19
错误:代码中意外的符号/输入/字符串常量/数值常数/特殊我收到了其中一个错误。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"
查看完整描述

2 回答

?
慕尼黑5688855

TA贡献1848条经验 获得超2个赞

对我来说,错误是:


Error: unexpected input in "�"

修补程序是在十六进制编辑器中打开脚本,并从文件中删除前3个字符。该文件是从一个UTF-8 BOM开始的,而且Rscript似乎无法读取它。


编辑:OP请求一个示例。开始吧。


➜  ~ cat a.R

cat('hello world\n')

➜  ~ xxd a.R

00000000: efbb bf63 6174 2827 6865 6c6c 6f20 776f  ...cat('hello wo

00000010: 726c 645c 6e27 290a                      rld\n').

➜  ~ R -f a.R        


R version 3.4.4 (2018-03-15) -- "Someone to Lean On"

Copyright (C) 2018 The R Foundation for Statistical Computing

Platform: 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.


  Natural language support but running in an English locale


R 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


查看完整回答
反对 回复 2019-07-06
  • 2 回答
  • 0 关注
  • 8636 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信