To setup locale in ubuntu

In terminal:

locale shows the locale currently used by your system
locale -a shows the locale present in your system
If one is missing, use :
sudo locale-gen fr_FR.UTF-8

and then sudo update-locale LANG=fr_FR.UTF-8 to define this as a default

The defaults are available here:
cat /etc/default/locale 

You can setup any of the following:
LANG=fr_FR.UTF-8
LANGUAGE=
LC_CTYPE=en_US.UTF-8
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

And now you can run 
system("ssh login@ipv4.ipv4.ipv4.ipv4 \"R -e 'print(1)'\"") 

without warning !

In R:
> Sys.getlocale()
[1] "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C"

Il faut laisser LC_NUMERIC à la valeur de C pour éviter un comportement étrange de R:

> Sys.setlocale(category = "LC_NUMERIC", locale="fr_FR.UTF-8")
[1] "fr_FR.UTF-8"
Warning message:
In Sys.setlocale(category = "LC_NUMERIC", locale = "fr_FR.UTF-8") :
  changer 'LC_NUMERIC' peut résulter en un fonctionnement étrange de R
> Sys.localeconv()
    decimal_point     thousands_sep          grouping   int_curr_symbol 
              ","               " "            "\003"            "EUR " 
  currency_symbol mon_decimal_point mon_thousands_sep      mon_grouping 
              "€"               ","               " "            "\003" 
    positive_sign     negative_sign   int_frac_digits       frac_digits 
               ""               "-"               "2"               "2" 
    p_cs_precedes    p_sep_by_space     n_cs_precedes    n_sep_by_space 
              "0"               "1"               "0"               "1" 
      p_sign_posn       n_sign_posn 
              "1"               "1" 
> 120.215
[1] 120,215

Only the display uses the coma for decimal point; the numbers are still entered with a .

Come back to more normal behavior:
Sys.setlocale(category = "LC_NUMERIC", locale="C")



Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04