rknitrlyx

Error when R starts up after using Sys.setlocale()


When loading RStudio, I get the following error message, which I don't understand:

Error: 3:35: unexpected symbol
3:     Sys.setlocale(, "en_US.UTF-8")Sys.setlocale
                                      ^

After having some encoding problems with knitr/LyX/R, I tried to set the locale with the following command found here, which I think caused it.

cat('
Sys.setlocale(, "en_US.UTF-8")
    ', file = '~/.Rprofile', append = TRUE)

How can I change my Sys.setlocale back to something that works? I have tried Sys.setlocale(category = "LC_ALL", locale = "en_US.UTF-8"), but without luck. I have also tried the following in Terminal as suggested here: defaults write org.R-project.R force.LANG en_US.UTF-8

I have the following output from sessionInfo()

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

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

Solution

  • The problem was solved by locating the .Rprofile in my home folder and deleting the content.