aphalo / ggpmisc

R package ggpmisc is an extension to ggplot2 and the Grammar of Graphics
https://docs.r4photobiology.info/ggpmisc
94 stars 6 forks source link

Support comma as decimal marker #34

Closed aphalo closed 1 year ago

aphalo commented 1 year ago

Make stat_poly_eq(), stat_quant_eq() and stat_ma_eq() fully respect R option options(OutDec = ","). It seems the model equation respects it but not R2 and possibly other labels. See https://stackoverflow.com/questions/74813032/modifying-the-decimal-mark-of-stat-poly-eq

aphalo commented 1 year ago

It seems that there is not clean way to fix this: stackoverflow.com/questions/23586741/… I will most likely have to add to the package the gsub() kludge to substitute the decimal marker. The root of the problem is that 'ggpmisc' code makes use of sprintf(), while sprintf() uses the operating system's locale setting. – 

aphalo commented 1 year ago

parse() needs always . as decimal marker on input and obeys R option OutDec for output, so the equation needs to be formatted differently only when output.type != "expression". Other labels are not parsed so as to preserve trailing zeros. stat_poly_eq() and internal functions are now revised to fix the bug. Other stats need to be similarly editted.

aphalo commented 1 year ago

Implemented in future v0.5.2 I did not implement overriding of the R option through a new formal parameter. If needed, it would be easy to implement but behviour would differ from 'ggplot2' and R's use of the OutDec option.