[Rd] Possible bug in formatC

Randy Cragun rc @end|ng |rom rcr@gun@net
Thu May 30 06:26:38 CEST 2019

I do not know if this is a bug or a case of improper documentation. The
documentation for formatC() implies that the difference between the options
format="f" and format="g" is that with "g", scientific format is sometimes
used. There is another difference between them that is not mentioned in the
documentation. drop0trailing=FALSE is ignored when format is set to "g"
unless flag contains "#" (this is the documented behavior for format="fg").
For instance, the first line below return " 2.5", whereas the second returns
the expected  "2.50".

formatC(2.50, format="g", digits=3, drop0trailing=F)
formatC(2.50, format="g", digits=3, drop0trailing=F, flag="#")


R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C

[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.5.3 tools_3.5.3

More information about the R-devel mailing list