Script with utf-8 text runs differently from RStudio and command line in Windows

后端 未结 2 1254
情书的邮戳
情书的邮戳 2021-01-03 02:09

I\'m working with files containing text in Hindi and parsing them. I wrote my code in Rstudio and executed it without many issues. But now, I need to execute the same script

2条回答
  •  悲&欢浪女
    2021-01-03 03:07

    You need to ensure that R is running in a suitable locale:

    Running rterm use: Sys.getlocale() to find your current locale.

    You can set your locale using:

    Sys.setlocale(category = "LC_ALL", locale = "hi-IN")
    
    # Try "hi-IN.UTF-8" too...
    

    You can find locale names here, the MSDN, and here.

    If you have the correct value, put the Sys.setlocale() command in your ~/.Rprofile.

    References

    • https://cran.r-project.org/bin/windows/base/rw-FAQ.html
    • http://withr.me/configure-character-encoding-for-r-under-linux-and-windows/

提交回复
热议问题