I'm a big fan of the + operator for string concatenation in Python. I would like to extend/customize the + operator to do the same thing in R.
Here's what I have so far:
`+` <- function(a, b){
if(is.numeric(a)){
sum(a, b)
}else{
paste0(a, b)
}
This works pretty well, but in some speed tests, performs poorly compared to the original/primitive +. So, how can I refer to the primitive + instead of sum() in the second line of the function? If I just use +, of course R gives me a node stack overflow from infinite recursion.