[英]Hi am a new R learner.. wrote below two identical code on editior, 2nd one runs fine, while first one has error.. what is wrong with 1st one
1st One第一个
Not run there is an error没有运行有错误
repeat{
sc=scan(nmax=1)
if (sc>9) {break} else{
b=switch(sc,"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE")
cat(“\n The Number Entered is “, sc ,” In Alpha it is “, b,”\n”) } }
the Error is Error: unexpected input in: "b=switch(sc,"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE") cat(“"错误是错误:意外输入:“b=switch(sc,”ONE”,”TWO”,”THREE”,”FOUR”,”FIVE”,”SIX”,”SEVEN”,”EIGHT”,”NINE “) 猫(””
2nd One This one runs ok第二个这个运行正常
repeat{
sc=scan(nmax=1)
if (sc>9) {break} else{
b=switch(sc,"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE")
cat("\n The Entered Number is ", sc ," In Alpha it is ", b,"\n") } }
1: 4 Read 1 item The Entered Number is 4 In Alpha it is FOUR 1:4 阅读 1 项 输入的数字是 4 在 Alpha 中是 4
“ is not allowed in R as a parentheses. " 不允许在 R 中作为括号。
In the first piece of code you are using “ instead of ".在第一段代码中,您使用“而不是”。
“ may appear if you copy your code into MS Word first and then into.R file.如果先将代码复制到 MS Word 中,然后再复制到 .R 文件中,可能会出现“。 To securely copy the code pls use Notepad (Notepad++ or IDE) so it preserves " symbol as is and does not transform it into “.
要安全地复制代码,请使用记事本(Notepad++ 或 IDE),这样它会按原样保留“符号,不会将其转换为”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.