OneBite.Dev - Coding blog in a bite size

assign multiple variables in R

Code snippet on how to assign multiple variables in R

a <- 3
b <- 4
c <- 6

This code assigns the integer values 3, 4 and 6 to three different variables named ‘a’, ‘b’ and ‘c’ respectively. The arrow operator (<-) assigns the integer values on the right to the variables on the left. The syntax is: [variable name] <- [integer value]. This is the same as saying, “assign the integer value on the right to the variable on the left”. The right side can be any valid R expression that returns a single value, for example 3x2 or sin(3). So the code above could also be written as: a <- 3; b <- 4; c <- 6.

r