考虑一个例子:

> mean(eta)
# [1] NA
# Warning message:
# In mean.default(eta) : l'argomento non è numerico o logico: restituisco NA

> Sys.setenv(LANG = "en")
> mean(eta)
# [1] NA
# Warning message:
# In mean.default(eta) : l'argomento non è numerico o logico: restituisco NA


我的renviron文件仍然无法正常工作:

### etc/Renviron.  Generated from Renviron.in by configure.
###
### ${R_HOME}/etc/Renviron
###
### Record R system environment variables.

Sys.setenv(LANGUAGE='en')
R_PLATFORM=${R_PLATFORM-'i686-pc-linux-gnu'}
## Default printer paper size: first record if user set R_PAPERSIZE
R_PAPERSIZE_USER=${R_PAPERSIZE-'a4'}
R_PAPERSIZE=${R_PAPERSIZE-'letter'}
## Default print command
R_PRINTCMD=${R_PRINTCMD-'/usr/bin/lpr'}


我认为问题是:

Sys.getenv(LANG)
Errore in Sys.getenv(LANG) : oggetto "LANG" non trovato


也:

Sys.getenv(LANGUAGE)
Errore in Sys.getenv(LANGUAGE) : oggetto "LANGUAGE" non trovato


也:

> sessionInfo()

R version 3.0.1 (2013-05-16)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=it_IT.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=it_IT.UTF-8        LC_COLLATE=it_IT.UTF-8
 [5] LC_MONETARY=it_IT.UTF-8    LC_MESSAGES=it_IT.UTF-8
 [7] LC_PAPER=C                 LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] entropy_1.2.0 ineq_0.2-11   moments_0.13

loaded via a namespace (and not attached):
[1] tools_3.0.1

> system("uname -a")

Linux lucas-K55VD 3.11.0-14-generic #21-Ubuntu SMP Tue Nov 12 17:07:40 UTC 2013 i6


也:

> 2+x
Errore: oggetto "x" non trovato
> Sys.getenv("LANG")
[1] "it_IT.UTF-8"
> Sys.setenv(LANG='en')
> Sys.getenv("LANG")
[1] "en"
> 2+x
Errore: oggetto "x" non trovato

> Sys.setenv(LANG="en_US-UTF-8")
> 2+x
Errore: oggetto "x" non trovato
> system("locale -a | grep '^en'")
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8

> Sys.setenv(LANG="en_US.utf8")
> 2+x
Errore: oggetto "x" non trovato


还有另一件事:如果stackoverflow一直阻止我尝试显示其他人的代码或控制台输出,我应该如何在此处显示R输出或代码?

最佳答案

请参见help(Startup)-必须在~/.Renviron中进行设置,以便在主R进程开始之前进行设置。

10-01 13:50