美文网首页
R启动报警 - 1: Setting LC_COLLATE fa

R启动报警 - 1: Setting LC_COLLATE fa

作者: GYBE | 来源:发表于2019-01-24 10:39 被阅读0次

    R启动报错如下:

    R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
    Copyright (C) 2018 The R Foundation for Statistical Computing
    Platform: x86_64-apple-darwin18.2.0 (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
      Natural language support but running in an English locale
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    [Previously saved workspace restored]
    
    During startup - Warning messages:
    1: Setting LC_COLLATE failed, using "C"
    2: Setting LC_TIME failed, using "C"
    3: Setting LC_MESSAGES failed, using "C"
    4: Setting LC_MONETARY failed, using "C"
    

    原因分析

    导致这种情况出现的原因是本地环境LANG配置错误, iterm2(终端)运行locale

    LANG=
    LC_COLLATE="C"
    LC_CTYPE="UTF-8"
    LC_MESSAGES="C"
    LC_MONETARY="C"
    LC_NUMERIC="C"
    LC_TIME="C"
    LC_ALL=
    

    解决办法

    1. 关闭R, 打开iterm2(终端), 运行一下命令:
    defaults write org.R-project.R force.LANG en_US.UTF-8
    
    1. 打开R, 运行以下命令:
    system("defaults write org.R-project.R force.LANG en_US.UTF-8")
    
    1. 配置环境, 笔主使用iterm2, 配置.zshrc
    vim ~/.zshrc
    # 加入如下配置
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    

    然后重启终端, 或者

    source ~/.zshrc
    

    笔主试过1,2 方法, 没有生效, 第3中方法生效.
    现在重新打开R, 你会发现告警信息已经不在了.


    相关文章

      网友评论

          本文标题:R启动报警 - 1: Setting LC_COLLATE fa

          本文链接:https://www.haomeiwen.com/subject/qgcyjqtx.html