[Rd] "+" operator on characters revisited

Spencer Graves spencer.graves at structuremonitoring.com
Sun Jan 23 18:10:39 CET 2011

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?


More information about the R-devel mailing list