What’s the most straight forward way of overloading ‘+’ for characters?
I have defined '%+%' <- function(...) paste(...,sep=""):
str <- "aa"%+%"bb"%+%"cc" #str="aabbcc"
But I don’t like the syntax. I think str <- "aa"+"bb"+"cc" would be nicer.
(I am building long SQL queries to use with RODBC, the usual paste is not very handy in such situations. Any suggestions?)
I think that using two arguments is better than the dots:
If you really really want to you can overwrite
+, but be veeeeery careful when doing this as you will break one of the most important functions in R. I can’t think of any reason why you would want to do that over%+%:commented it out to be sure I don’t accidently break someones R:)