[Rd] formatC(character()) returns length 1 result, but is documented otherwise

Davis Vaughan d@v|@ @end|ng |rom r@tud|o@com
Mon Sep 13 22:35:47 CEST 2021


Hi all,

I believe I have either found a small bug, or a possible inconsistency in
documentation. formatC() returns a length 1 result if given a length 0
character() as input.

formatC(character())
#> [1] ""

But the return value documentation states that it returns: "A character
object of same size and attributes as x".

I'd love for this to return a size 0 result here, consistent with the docs
and my mental model of size stability for this function.

Here is where this happens (it is explicitly hard coded):
https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/library/base/R/format.R#L149

Thanks,
Davis Vaughan

	[[alternative HTML version deleted]]



More information about the R-devel mailing list