0Pricing
R Academy · Lesson

Arithmetic and Comparison Operators

Learn +, -, *, /, %%, %/% and comparison operators in R.

Introduction to R Operators

Operators are symbols that tell R to perform specific operations. In this lesson, we explore arithmetic and comparison operators — the foundation of any R program.

R supports all standard math operations plus some unique ones like modulo and integer division.

# Basic arithmetic in R
x <- 10
y <- 3
cat('x =', x, ', y =', y, '
')

Addition and Subtraction

The + and - operators work exactly as in mathematics. They can be applied to single values or entire vectors at once.

price <- 49.99
discount <- 5.00
final_price <- price - discount
tax <- final_price + 3.50
cat('Final price with tax:', tax, '
')

All lessons in this course

  1. Arithmetic and Comparison Operators
  2. Logical Operators and Boolean Logic
  3. Assignment and Special Operators
  4. Operator Precedence and Complex Expressions
← Back to R Academy