在R-Studio中使用sourcing时遇到一些奇怪的编码问题,但在开发脚本时直接按ctrl +进入则没有。基本上,我创建了一个data.frame,存储来自不同语言的单词及其英文翻译。这工作正常,直到我来源。我意识到这可能是编码问题,但我真的不确定如何继续,也不完全理解为什么我得到的错误(意外的INCOMPLETE_STRING)只发生在源码上。在每种语言更改之前,我是否需要更改编码?我怎么知道哪个编码是正确的?
感谢您的帮助。这是代码:
translator = data.frame('RESULT' = character(),'english' = character(),stringsAsFactors = FALSE)
translator[1,] = c('Completed','Completed') #English
translator[2,] = c('Failed','Failed') #English
translator[3,] = c('User canceled','Canceled') #English
translator[4,] = c('完了','Completed') #chinese
translator[5,] = c('已完成','Completed') #Chinese
translator[6,] = c('失败','Failed') #Chinese
translator[7,] = c('用户取消','Canceled') #Chinese
translator[8,] = c('ユーザーによる取り消し','Canceled') #japanese
translator[9,] = c('エラー','Failed') #japanese
translator[10,] = c('Completata','Completed') #Italian
translator[11,] = c('Fallita','Failed') #Italian
translator[12,] = c('Annullata','Canceled') #Italian
translator[13,] = c('Finalizado','Completed') #Spanish
translator[14,] = c('Cancel usuario','Canceled') #Spanish
translator[15,] = c('Fallido','Failed') #Spanish
translator[16,] = c('Cancelado utili.','Canceled') #Spanish
translator[17,] = c('Terminé','Completed') #French
translator[18,] = c('Annulé par utilis.','Canceled') #French
translator[19,] = c('Echoué','Failed') #French
translator[20,] = c('Abgeschlossen','Completed') #German
translator[21,] = c('Benutzerabbruch','Canceled') #German
translator[22,] = c('Fehlgeschlagen','Failed') #German
translator[23,] = c('Concluído','Completed') #Portuguese
translator[24,] = c('Falhado','Failed') #Portuguese
translator[25,] = c('Doko','Completed') #Czech
translator[26,] = c('Zru','Canceled') #Czech
translator[27,] = c('Chyba','Failed') #Polish
translator[28,] = c('Отмена','Canceled') #Russian
translator[29,] = c('Готово','Completed') #Russian
translator[30,] = c('Ошибка','Failed') #Russian
答案 0 :(得分:0)
' INCOMPLETE_STRING'很可能意味着没有为文件中的字符设置编码/语言环境。这两个链接可能有所帮助:
How to source() .R file saved using UTF-8 encoding?
unexpected-incomplete-string-error-when-printing-chinese-word