<- (assignment)
Try it yourself →Assigns a value to a variable.
Syntax
name <- value
Description
Assignment in R is done with <- (= also works). The type is inferred from the value; the value can be changed later. class(x) returns the type.
Example
name <- "R" score <- 10 score <- 20 cat(name, "\n", sep="") cat(score, "\n", sep="")
Expected output
R 20
When to use?
General-purpose variable definition.