In R, you can perform a variety of basic operations, including arithmetic, logical, and comparison operations. Here’s a summary of these operations with examples:
## Addition and Subtraction
sum <- 3 + 2 # Addition
difference <- 5 - 3 # Subtraction
sum
## [1] 5
difference
## [1] 2
8 + 4 - 3
## [1] 9
product <- 4 * 2 # Multiplication
product
## [1] 8
10 * 2
## [1] 20
10*3^2
## [1] 90
quotient <- 8 / 4 # Division
quotient
## [1] 2
10/20
## [1] 0.5
10/5
## [1] 2
power <- 2^3 # Exponentiation
power
## [1] 8
2 * (30 + 23)
## [1] 106