I used a R package written by other people. In the package, it is supposed to create a file name as \"Mar.12\". However the file name is \"三月.12” in my system since I am run
More info : https://stat.ethz.ch/R-manual/R-devel/library/base/html/locales.html
You'll get all your local variables through : sessionInfo()
Sys.getlocale()
Sys.getlocale("LC_TIME")
OK, as a Q&A site, it seems an answer is required. From your description, it appears to be the issue of your locales. Read ?locales
for more.
You can have a test with this (read ?strptime
for various format, and pay special attention to those sensitive to locales):
format(Sys.Date(), format = "%Y-%b-%d")
# [1] "2016- 9月-06"
The output has the month in Chinese. If I want to change the display, I need to set "LC_TIME"
locale to "C"
:
Sys.setlocale("LC_TIME", "C")
Then it is OK:
format(Sys.Date(), "%Y-%b-%d")
# [1] "2016-Sep-06"
Every time you start a new R session, you get back to native setting. Should you want a permanent change, put
.First <- function() {
Sys.setlocale("LC_TIME", "C")
}
in the $(R RHOME)/etc/Rprofile.site
file. Read ?Startup
for how to customize R startup and the use of .First
.