0
在R-Studio中使用源代碼時,我遇到了一些奇怪的編碼問題,但在開發腳本時直接按Ctrl + Enter時沒有。基本上,我創建一個data.frame存儲來自不同語言的單詞以及他們的英文翻譯。這工作正常,直到我來源。我意識到這可能是編碼問題,但我真的不知道如何繼續,也不完全明白爲什麼我得到的錯誤(意外的INCOMPLETE_STRING)只發生在源代碼中。在每次更改語言之前是否需要更改編碼?我怎麼知道哪個編碼是正確的?R編碼與源代碼錯誤,但不是在控制檯中
感謝您的任何幫助。以下是代碼:
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
謝謝你,得到的答覆是:的eval(解析(文件名,編碼= 「UTF-8」))來自一個帖子點擊:http:// stackoverflow.com/questions/5031630/how-to-source-r-file-saved-using-utf-8-encoding – HEITZ