# The syntax for creating new binary operators in R is unlike anything else in# R, but it allows you to define a new syntax for your function. I would only# recommend making your own binary operator if you plan on using it often!## User-defined binary operators have the following syntax:# %[whatever]% # where [whatever] represents any valid variable name.# # Let's say I wanted to define a binary operator that multiplied two numbers and# then added one to the product. An implementation of that operator is below:## "%mult_add_one%" <- function(left, right){ # Notice the quotation marks!# left * right + 1# }## I could then use this binary operator like `4 %mult_add_one% 5` which would# evaluate to 21.## Write your own binary operator below from absolute scratch! Your binary# operator must be called %p% so that the expression:## "Good" %p% "job!"## will evaluate to: "Good job!""%p%" <- function(left,right){ # Remember to add arguments!
paste(left,right)
}
> 'I' %p% 'love' %p% 'R!'
[1] "I love R!"