From csardi.gabor at gmail.com  Wed Jun 17 18:56:54 2015
From: csardi.gabor at gmail.com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Wed, 17 Jun 2015 12:56:54 -0400
Subject: [Rd] Improving string concatenation
In-Reply-To: <CAF8bMcZ1pRVVN2ZhDZ1EEq_vMN_1WzNvyw1e24cE=TDa=m+mmQ@mail.gmail.com>
References: <CAKShX4A5bVtxVAG+01QjNH0=LaVr6MH48xXs-OtbQQ2247cc_g@mail.gmail.com>
	<CADwqtCMPAbayj7TENRPtPSXjyFi7wjWfdW9qke7n+PExdwkpbw@mail.gmail.com>
	<CAKShX4D-LHgmh5cO2xxnLypzSgCWLDEnHopfE00MwbRFpRvmLg@mail.gmail.com>
	<CAF8bMcZ1pRVVN2ZhDZ1EEq_vMN_1WzNvyw1e24cE=TDa=m+mmQ@mail.gmail.com>
Message-ID: <CABtg=KnxaG+7ysX4=fWWzkfCvUkG408YvEwNxT0W1WLEHOJZ4A@mail.gmail.com>

On Wed, Jun 17, 2015 at 12:45 PM, William Dunlap <wdunlap at tibco.com> wrote:
>> ... adding the ability to concat
>> strings with '+' would be a relatively simple addition (no pun intended)
> to
>> the code base I believe. With a lot of other languages supporting this
> kind
>> of concatenation, this is what surprised me most when first learning R.
>
> Wow!  R has a lot of surprising features and I would have thought
> this would be quite a way down the list.

Well, it is hard to guess what users and people in general find
surprising. As '+' is used for string concatenation in essentially all
major scripting (and many other) languages, personally I am not
surprised that this is surprising for people. :)

> How would this new '+' deal with factors, as paste does or as the current
> '+'
> does?

The same as before. It would not change the behavior for other
classes, only basic characters.

> Would number+string and string+number cause errors (as in current
> '+' in R and python) or coerce both to strings (as in current R:paste and
> in perl's '+').

Would cause errors, exactly as it does right now.

> Having '+' work on all types of data can let improperly imported data
> get further into the system before triggering an error.

Nobody is asking for this. Only characters, not all types of data.

> I see lots of
> errors
> reported on this list that are due to read.table interpreting text as
> character
> strings instead of the numbers that the user expected.  Detecting that
> error as early as possible is good.

Isn't that a problem with read.table then? Detecting it there would be
the earliest possible, no?

Gabor

[...]



[Rd] Improving string concatenation
=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=