[Rd] string concatenation operator (revisited)

Grant McDermott gr@ntmcd @end|ng |rom uoregon@edu
Fri Dec 10 19:57:12 CET 2021

Sorry I haven't had a chance to reply to anyone. I feel like I dropped a grenade in a room and promptly bolted...

Just to say, then, that I really appreciate everyone's comments and suggestions. While I'm tempted to push back on some points, I don't think it's worth on balance, or will add much beyond what's already been said.

It's interesting to see that there appears to be at least some appetite for additional (f)string operators in base R... notwithstanding the valid objections and the difficulties raised in this thread.


Get Outlook for Android<https://aka.ms/AAb9ysg>
From: Grant McDermott
Sent: Saturday, December 4, 2021 12:36:44 PM
To: r-devel using r-project.org <r-devel using r-project.org>
Subject: string concatenation operator (revisited)

Hi all,

I wonder if the R Core team might reconsider an old feature request, as detailed in this 2005 thread: https://stat.ethz.ch/pipermail/r-help/2005-February/thread.html#66698

The TL;DR version is base R support for a `+.character` method. This would essentially provide a shortcut to `paste​0`, in much the same way that `\(x)` now provides a shortcut to `function(x)`.

> a = "hello "; b = "world"
> a + b
> [1] "hello world"

I appreciate some of the original concerns raised against a native "string1 + string2" implementation. The above thread also provides several use-at-your-own-risk workarounds. But sixteen years is a long time in software development and R now stands as something of an exception on this score. Python, Julia, Stata, and SQL (among various others) all support native string concatenation/interpolation using binary/arithmetic operators. It's been a surprising source of frustration for students in some of the classes I teach, particularly those coming from another language.

Many thanks for considering.

PS. I hope I didn't miss any additional discussion of this issue beyond the original 2005 thread. My search efforts didn't turn anything else up, except this popular Stackoverflow question: https://stackoverflow.com/questions/4730551/making-a-string-concatenation-operator-in-r

Grant McDermott
Assistant Professor
Department of Economics
University of Oregon

	[[alternative HTML version deleted]]

More information about the R-devel mailing list