I was wondering how one might go about writing a string concatenation operator in R, something like || in SAS, + in Java/C# or & in Visual Basic.
The easiest way would be to create a special operator using %, like
`%+%` <- function(a, b) paste(a, b, sep="")
but this leads to lots of ugly %
's in the code.
I noticed that +
is defined in the Ops group, and you can write S4 methods for that group, so perhaps something like that would be the way to go. However, I have no experience with S4 language features at all. How would I modify the above function to use S4?