Assignment Operators
Assignment Operators in R are used to assigning values to various data objects in R. The objects may be integers, vectors, or functions. These values are then stored by the assigned variable names. There are two kinds of assignment operators: Left and Right
Left Assignment (<- or <<- or =)
Assigns a value to a vector.
vec1 = c("ab", TRUE)
print (vec1)
Output : "ab" "TRUE"
Right Assignment (-> or ->>)
Assigns value to a vector.
c("ab", TRUE) ->> vec1
print (vec1)
Output : "ab" "TRUE"
The following R code illustrates the usage of all Relational Operators in R:
# R program to illustrate
# the use of Assignment operators
vec1 <- c(2:5)
c(2:5) ->> vec2
vec3 <<- c(2:5)
vec4 = c(2:5)
c(2:5) -> vec5
# Performing operations on Operands
cat ("vector 1 :", vec1, "\n")
cat("vector 2 :", vec2, "\n")
cat ("vector 3 :", vec3, "\n")
cat("vector 4 :", vec4, "\n")
cat("vector 5 :", vec5)
Output
vector 1 : 2 3 4 5
vector 2 : 2 3 4 5
vector 3 : 2 3 4 5
vector 4 : 2 3 4 5
vector 5 : 2 3 4 5
R Operators
Operators are the symbols directing the compiler to perform various kinds of operations between the operands. Operators simulate the various mathematical, logical, and decision operations performed on a set of Complex Numbers, Integers, and Numericals as input operands.
Contact Us