What is the difference between the ‘<<-' and '<-' assignment operators in R?

1 Answers
Answered by suresh

Difference between the '<<-' and '<-' assignment operators in R

Difference between the '<<-' and '<-' assignment operators in R

In R programming, the '<-' assignment operator is used to assign a value to a variable in the current environment. It creates or updates a variable in the current environment.

On the other hand, the '<<-' assignment operator is used to assign a value to a variable in the parent environment of the current environment. It will look for a variable in the parent environment and assign the value if found, otherwise it will create a new variable in the parent environment.

Therefore, the main difference between '<-' and '<<-' operators is in the scope of where the variable is being created or updated - '<-' operates in the current environment while '<<-' operates in the parent environment.

Answer for Question: What is the difference between the ‘<<-' and '<-' assignment operators in R?