You fed it two characters, "dash" and "space" and it only wanted one character 
so it truncated to the first character and warned you that that's what it did.

If you had your space before the dash, it would have used that as your 
replacement character

> prettyNum(0, zero.print = " - ", replace = TRUE)

[1] " "

Warning message:
In .format.zeros(x, zero.print, replace = replace.zero) :
  'zero.print' is truncated to fit into formatted zeros; consider 'replace=TRUE'


When zero.print is only one character, it doesn't give a warning.


Tim

> -----Original Message-----
> From: R-help <r-help-boun...@r-project.org> On Behalf Of Marttila Mikko via
> R-help
> Sent: Friday, May 23, 2025 7:07 AM
> To: R mailing list <r-help@r-project.org>
> Subject: [R] Formatting zeroes with prettyNum
>
> ATTENTION: This email came from an external source. Do not open
> attachments or click on links from unknown senders or unexpected emails.
>
>
> Dear list,
>
> Have I stumbled upon a bug, or am I holding `prettyNum()` wrong? Please see
> below.
>
> Best,
>
> Mikko
>
> > prettyNum(0, zero.print = "- ", replace.zero = TRUE)
> [1] "-"
> Warning message:
> In .format.zeros(x, zero.print, replace = replace.zero) :
>   'zero.print' is truncated to fit into formatted zeros; consider 
> 'replace=TRUE'
>
> > prettyNum(0, zero.print = "- ", replace = TRUE)
> [1] "-"
> Warning message:
> In .format.zeros(x, zero.print, replace = replace.zero) :
>   'zero.print' is truncated to fit into formatted zeros; consider 
> 'replace=TRUE'
>
>
>
> This e-mail transmission may contain confidential or legally privileged
> information that is intended only for the individual or entity named in the e-
> mail address. If you are not the intended recipient, you are hereby notified
> that any disclosure, copying, distribution, or reliance upon the contents of 
> this
> e-mail is strictly prohibited. If you have received this e-mail transmission 
> in
> error, please reply to the sender, so that they can arrange for proper 
> delivery,
> and then please delete the message from your computer systems. Thank you.
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.e/
> thz.ch%2Fmailman%2Flistinfo%2Fr-
> help&data=05%7C02%7Ctim.howard%40dec.ny.gov%7Cca52f6706ec24a30
> d68108dd99e9f6eb%7Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0%7C0%
> 7C638835952464135918%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hc
> GkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIld
> UIjoyfQ%3D%3D%7C60000%7C%7C%7C&sdata=hxfpM4LqaLhNXyPEbPXtck
> 7QNxBfFvak8HMpcxfAhgE%3D&reserved=0
> PLEASE do read the posting guide
> https://www/.
> r-project.org%2Fposting-
> guide.html&data=05%7C02%7Ctim.howard%40dec.ny.gov%7Cca52f6706ec
> 24a30d68108dd99e9f6eb%7Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0
> %7C0%7C638835952464154131%7CUnknown%7CTWFpbGZsb3d8eyJFbXB
> 0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFp
> bCIsIldUIjoyfQ%3D%3D%7C60000%7C%7C%7C&sdata=V7UNP8FDNZaNGal
> uKgb4Kjr6qSCVLhAhk5vU2y1sixg%3D&reserved=0
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to