On Thu, May 8, 2014 at 3:35 AM, Barry Rowlingson <
b.rowlingson@lancaster.ac.uk> wrote:
[...]

This is an example to show to everyone who says "Can we use + to
> concatenate strings in R please!?".
>

This is one of my main complaints against the R syntax. In general, R code
is often somewhat unreadable, and the lack of a string concatenation
operation is one of the worst imo, so I have say something here.

"+" in R does not have this problem that JavaScript has above, because
minus does not convert strings to numbers. "We" do not want the define the
two-operand minus operation for strings, either. I.e. "we" (I, really) want

> "2" + "1"
[1] "21"
> "2" - "1"
Error in "2" - "1" : non-numeric argument to binary operator
> "2" - - "1"
Error in -"1" : invalid argument to unary operator

What is wrong with this, again?

Btw. there are several languages with string concatenation operators, and
without the JS problem you mentioned, e.g. this is Python:

>>> "2" + "1"
'21'
>>> "2" - "1"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'str' and 'str'
>>> "2" - - "1"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bad operand type for unary -: 'str'

Gabor

	[[alternative HTML version deleted]]

