rwindowsdecimal-point

How to find out which symbol is used as a decimal / list separator?


I want to export a table using write.csv. There are 2 flavors of write.csv changing the defaults for the field and the decimal separator.

I want, however, to use the local regional setting (which may be altered from the locale by the user):

Region Settings

Thus, for this user I would like to use . as a decimal separator and ; as a field separator. How could I query these settings from R?


Solution

  • You can query the corresponding registry entries following https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg-query

    For example:

    # get list separator
    system('reg query "HKEY_CURRENT_USER\\Control Panel\\International" /v sList', intern = TRUE)
    
    # get decimal symbol
    system('reg query "HKEY_CURRENT_USER\\Control Panel\\International" /v sDecimal', intern = TRUE)
    

    Sorry, I'm not familiar with Window's built-in command line cmd & I can't find out how to only extract the value itself. However, this can easily be done in R...

    Works on my Windows 10 virtual machine...