How to set ',' as decimal separator with R

后端 未结 3 1680
陌清茗
陌清茗 2021-01-04 10:29

Even though my Windows 7 locale settings specify using \",\" as a decimal separator, R and RStudio give me a \".\" separator. Is there any way to change this? Note the \"LC_

3条回答
  •  悲&欢浪女
    2021-01-04 11:20

    Why do you want to use "," as decimal separator, in that case how R will interprate this R expression

    x <- c(2,3) # (two vectors or one). 
    

    So, I assume that you just want to override the default decimal separator to print an output and in this case, I think prettyNum is the right tool.

    require(plyr)
    head(numcolwise(prettyNum)(iris, dec = ","))
    
    ##   Sepal.Length Sepal.Width Petal.Length Petal.Width
    ## 1          5,1         3,5          1,4         0,2
    ## 2          4,9           3          1,4         0,2
    ## 3          4,7         3,2          1,3         0,2
    ## 4          4,6         3,1          1,5         0,2
    ## 5            5         3,6          1,4         0,2
    ## 6          5,4         3,9          1,7         0,4
    

提交回复
热议问题