How to Use Infix Operators In R Programming

Infix functions (operators) can help clean up your data model and maintain preferences for an order of operation

Pierre DeBois
Analytics Vidhya

--

An example of creating and invoking an infix function in R Programming

Most of the functions in R programming are written with the arguments set within a parenthesis. But once in a while, the order of arguments needs a different format to keep an intended order of expression. Infix operators (also called “infix functions”) provide that different format, a syntax for pairing arguments while providing a mathematical order of expressions recognized by the program.

Infix operators are not a usual choice — there are many ways to create a function, like the new operator for R programming which I explain in this post. Yet data science and programmers can use infix functions to expand their options. It can be a great way to simplify formulas applied to arrays and matrices — a need that comes up frequently with data placed in data frames, data tables, and other classes of objects.

What Is An Infix?

So let’s get the basics out of the way. What is an infix operator? What does it do?

An infix operator is a function that applies a calculation to arguments on either side of the function operand. In R the operand involves a function name surrounded by…

--

--

Pierre DeBois
Analytics Vidhya

#analytics |#datascience |#JS |#rstats |#marketing services for #smallbiz | #retail | #nonprofits Contrib @CMSWire @smallbiztrends #blackbusiness #BLM