pillar icon indicating copy to clipboard operation
pillar copied to clipboard

Better decimal formatting

Open drvictorvs opened this issue 3 years ago • 4 comments

Makes sure that pillar formats decimals according to the decimal mark defined by the user with the OutDec option (as described in help("options")).

I was in doubt whether I should have added any sort of validation to OutDec. I initially wrote it to default to . in EN locales and , in certain European locales, and to accept the OutDec value only if it was a character and length 1. I figured the length was especially important given how pillar deals with screen width. I assumed base would also have such checks. However, out of curiosity I set OutDec to "potato" to see how the base print function would deal with it, and indeed it printed 0.1 as [1] 0potato1. Why should I take that away from users?

So, I didn't add the length requirement, but I imagine you would like to do that, as well as add some sort of type validation. Regardless, the important thing is that pillar respects the OutDecoption.

Best regards.

drvictorvs avatar Dec 22 '22 17:12 drvictorvs

Thanks.

@hadley: Should our printing depend on getOption("OutDec") ?

krlmlr avatar Mar 12 '23 10:03 krlmlr

Hmmm, this seems like a change with potentially unexpected consequences, so we’d need to carefully analyse to know whether or not it’s worth.

hadley avatar Mar 14 '23 14:03 hadley