R Operators: Arithmetic, Rational, Logical 

Learn about the 3 main types of operators: arithmetic, rational, and logical.

This tutorial will teach you the basics of R. It is not necessary to have any prior programming experience.

The previous video focused on variables, in this video of the Beginning R Programming series we R operators.

If you want to do a quick calculation on some numeric values, such as calculating the difference between values or compare values to see if they match or meet a certain condition, then you’ll need to know the different operators you can work with.

They are not only useful for doing calculations on data but can also:

  • be used to compare values

  • set up conditions for values

Arithmetic is your typical addition, subtraction, multiplication, division remainder, and exponent.

Rational and logical operators allow us to compare data values to see if they match, don’t match, are above, below, or equal to numeric thresholds, or extract data that meet a number of these conditions. Your rational operators include checking if a numeric value is:

  • greater than or less than a threshold

  • is greater than or equal to

  • is less than or equal to

Your logical operators include:

  • “and”

  • “or”

  • “not”

You use “and” when you want to extract data that meets both one condition and the other condition or more. And “or” means that data will be extracted if it only meets one of these conditions or options that apply.

To get started watch the video

In the next video, we will study Read and Write Data in R.