简体   繁体   中英

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

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

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

Can I edit this?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM