From spencer.graves at structuremonitoring.com  Sun Jan 23 18:10:39 2011
From: spencer.graves at structuremonitoring.com (Spencer Graves)
Date: Sun, 23 Jan 2011 09:10:39 -0800
Subject: [Rd] "+" operator on characters revisited
In-Reply-To: <E410A01D-653A-434F-B971-9EAC08324AC8@gmail.com>
References: <878vycd7ld.fsf@gmail.com>
	<E410A01D-653A-434F-B971-9EAC08324AC8@gmail.com>
Message-ID: <4D3C610F.4000005@structuremonitoring.com>

On 1/23/2011 8:50 AM, peter dalgaard wrote:
> On Jan 22, 2011, at 21:08 , Vitalie S. wrote:
>
>> The only definite argument occurred in the thread against "+" operator
>> was the lack of commutativity (as if one have to prove algebraic
>> theorems in R).
> I think the real killer was associativity, combined with coercion rules:
>
> Is "x"+1+2 supposed to be equal to "x12" or "x3"?
>
       Excellent:  This seems like a good reason to follow Python:  
Allow "a+b" with a character vector "a" only if "b" is also a character 
vector (or factor?).


       This example raises another question:  If we allow "a+b" for "a" 
and "b" both character vectors (and give an error if one is numeric), 
what do we do with factors?  If "a" is a factor, return a factor?


       Spencer



[Rd] "+" operator on characters revisited
Spencer Graves