R(1):中文亂碼解決方案

  •  讀取csv文件出現中文亂碼方案,增長編碼格式參數
    read.csv(trainPath,header=TRUE,stringsAsFactors=TRUE,encoding = "UTF-8")
  • 保存csv文件中出現亂碼,編碼格式參數
    write.csv(outp, file = path, quote = F, fileEncoding = "UTF-8")
  • source 加載R腳本中文亂碼
    source("core.R",encoding="utf-8")
  • RStudio中腳本中文亂碼,編碼格式設置:tools -> global option...., 以下圖:
  • source加載R腳本waring, 函數及變量加載不進來的問題
    > source("core.R",encoding="utf-8")
    Warning message: In readLines(file, warn = FALSE) :
      invalid input found on input connection 'core.R'
  •  R語言環境的顯示問題html

    > sessionInfo() R version 3.2.5 (2016-04-14)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    Running under: Windows >= 8 x64 (build 9200)
    
    locale:
    [1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936    LC_MONETARY=Chinese (Simplified)_China.936
    [4] LC_NUMERIC=C                               LC_TIME=Chinese (Simplified)_China.936    
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] plyr_1.8.4   DT_0.2       RODBC_1.3-13
    
    loaded via a namespace (and not attached):
    [1] htmlwidgets_0.7 magrittr_1.5    htmltools_0.3.5 tools_3.2.5     Rwordseg_0.2-1  Rcpp_0.12.6     digest_0.6.9   
    > Sys.getlocale() [1] "LC_COLLATE=Chinese (Simplified)_China.936;LC_CTYPE=Chinese (Simplified)_China.936;LC_MONETARY=Chinese (Simplified)_China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_China.936"
    > Sys.setlocale(category = "LC_ALL",local="us") [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
    > Sys.setlocale(category = "LC_ALL",local="chinese") [1] "LC_COLLATE=Chinese (Simplified)_China.936;LC_CTYPE=Chinese (Simplified)_China.936;LC_MONETARY=Chinese (Simplified)_China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_China.936"
相關文章
相關標籤/搜索