Search This Blog

Tutorial # 2. Operators

Arithmetic Operators
 

x = c(1,2,3)
y = c(4,5,6)

# Addition:
cat ("Addition is : ", x+y , "\n")

# Subtraction:
cat ("Subtraction is : ", x-y, "\n")

# Multiplication:
cat ("Multiplication is : ", x*y, "\n")

# Division:
cat ("Division is : ", x/y, "\n")

# Remainder:
cat ("Remainder is : ", x%%y, "\n")

# Exponentiation:
cat ("Exponentiation is : ", x^y, "\n")



Relational Operators 


print(x<y)

cat (x ," < ", y, " : " ,x < y ,"\n")
cat (x ," > ", y, " : " ,x > y, "\n")
cat (x ," == ", y, " : " ,x == y,"\n" )
cat (x ," <= ", y, " : " ,x <= y, "\n")
cat (x ," >= ", y, " : " ,x >= y, "\n")
cat (x ," != ", y, " : " ,x != y, "\n")
 

You may also interested in:

An Introduction to language R
Tutorial # 1.Data Type & Variable  Declaration
Tutorial # 2.Operators
Tutorial # 3.Vector  & Element Access
Tutorial # 4.Matrix
Tutorial # 5.Data Frame
Tutorial # 6.Arrays
Tutorial # 7.Lists
Tutorial # 8.Factors
Tutorial # 9.Data import
Tutorial # 10.Machine Learning
Tutorial # 11.Visualization


 

Post a Comment

0 Comments