[Rd] string concatenation operator (revisited)

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Sun Dec 5 08:41:05 CET 2021


Hello,

Bert Gunter started a very recent R-Help thread [1] about the following 
method not working.

`+.character` <- function(x, y) paste0(x, y)


The discussion is worth reading and at least partly answers to the 
reason why the feature request has never made it to base R.

It goes without saying that I do not speak for the R Core team.


[1] https://stat.ethz.ch/pipermail/r-help/2021-December/473163.html


Hope this helps,

Rui Barradas

Às 22:36 de 04/12/21, Grant McDermott escreveu:
> 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
> www.grantmcdermott.com
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list