Home > database >  In ggscatter in R, can I use "," instead the "." on the r and p-value?
In ggscatter in R, can I use "," instead the "." on the r and p-value?

Time:11-17

I am using ggscatter to a correlation graphic. It works, with de Pearson correlation (r) correct. However, I am Brazilian, and the decimal-point is defined by the "," instead the ".".

Examples: r = 0,81 instead the english-form r = 0.81

Can I edit this?

CodePudding user response:

As asked a few days ago with this question: Error in parse(text ...) unexpected comma "," when plotting ggplot with ggpubr::stat_cor and output decimal set to comma (options(OutDec = ",")) You can use a workaround that is by setting the output decimal option to a comma and output type of the coefficients to text in output.type like this:

library(ggpubr)
#> Loading required package: ggplot2
options(OutDec= ",") 
ggscatter(mtcars, x = "wt", y = "mpg",
          add = "reg.line", 
          cor.coef = TRUE, 
          cor.coeff.args = list(method = "pearson", output.type="text"))
#> `geom_smooth()` using formula = 'y ~ x'

Created on 2022-11-16 with reprex v2.0.2

There is also an issue on GitHub for this.

  • Related