1

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
avriis
  • 1,581
  • 4
  • 17
  • 31
  • 1
    Remove the second `Sys.setlocale(, "en_US.UTF-8")` from `Sys.setlocale(, "en_US.UTF-8")Sys.setlocale` in `.Rprofile` first. And don't run the `cat` command again. –  Jan 15 '16 at 07:58
  • I think it's just missing a semicolon (or newline) between the two calls to `Sys.setlocale` in your `.Rprofile`. You can always edit it manually, though. The error didn't actually screw up your system `locale` variables. – alistaire Jan 15 '16 at 08:05
  • @alistaire There is no need to call several time `Sys.setlocale`. OP ran 2 times or more the `cat` command, when once is only needed. –  Jan 15 '16 at 08:08
  • @Pascal True. Guess I learned that `cat(... append = TRUE)` doesn't insert a newline. – alistaire Jan 15 '16 at 08:18

1 Answers1

2

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

avriis
  • 1,581
  • 4
  • 17
  • 31