[Rd] paste(character(0), collapse="", recycle0=FALSE) should be ""

Gabriel Becker g@bembecker @end|ng |rom gm@||@com
Sun May 24 09:26:37 CEST 2020


On Sat, May 23, 2020 at 9:59 PM Hervé Pagès <hpages using fredhutch.org> wrote:

> On 5/23/20 17:45, Gabriel Becker wrote:
> > Maybe my intuition is just
> > different but when I collapse multiple character vectors together, I
> > expect all the characters from each of those vectors to be in the
> > resulting collapsed one.
>
> Yes I'd expect that too. But the **collapse** operation in paste() has
> never been about collapsing **multiple** character vectors together.
> What it does is collapse the **single** character vector that comes out
> of the 'sep' operation.
>

I understand what it does, I broke ti down the same way in my post earlier
in the thread. the fact remains is that it is a single function which
significantly muddies the waters. so you can say

paste0(x,y, collapse=",", recycle0=TRUE)

is not a collapse operation on multiple vectors, and of course there's a
sense in which you're not wrong (again I understand what these functions
do), but it sure looks like one in the invocation, doesn't it?

Honestly the thing that this whole discussion has shown me most clearly is
that, imho, collapse (accepting ONLY one data vector) and paste(accepting
multiple) should never have been a single function to begin with.  But that
ship sailed long long ago.




> So
>
>    paste(x, y, z, sep="", collapse=",")
>
> is analogous to
>
>    sum(x + y + z)
>

Honestly, I'd be significantly more comfortable if

1:10 + integer(0) + 5

were an error too.

At least I'm consistent right?

~G

	[[alternative HTML version deleted]]



More information about the R-devel mailing list