码迷,mamicode.com
首页 > 其他好文 > 详细

中文乱码解决方案

时间:2017-04-18 09:59:55      阅读:676      评论:0      收藏:0      [点我收藏+]

标签:mingw   中文   under   iges   blog   logs   lines   文件中   base   

  •  读取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语言环境的显示问题

    > 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"

   

中文乱码解决方案

标签:mingw   中文   under   iges   blog   logs   lines   文件中   base   

原文地址:http://www.cnblogs.com/tgzhu/p/6721501.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!