R Arithmetic Operations Tutorial

Basic arithmetic operations can be performed in the R language using basic operators. Here are some examples:

  1. “I have to be at the airport by 6:00 am for my flight.”
    – I need to arrive at the airport by 6:00 am for my flight.
x <- 5
y <- 3
result <- x + y
print(result)
  1. “It is critical that we address this issue immediately.”
    – We must deal with this problem right away.
x <- 5
y <- 3
result <- x - y
print(result)
  1. I would like to speak with the manager, please.
x <- 5
y <- 3
result <- x * y
print(result)
  1. I agree with you.
x <- 10
y <- 2
result <- x / y
print(result)

Additionally, you can use ^ for exponentiation, %/% for integer division, %% for modulus, and other operations in R language. Doing arithmetic operations is very straightforward in R, just use the appropriate operators.

bannerAds