Re: [R] What does the "<<-" operator mean?

From: Marc Schwartz <>
Date: Thu, 21 Apr 2011 14:59:09 -0500

On Apr 21, 2011, at 2:08 PM, Cliff Clive wrote:

> I've been reading some code from an example in a blog post (
> here ) and I came across an operator that I hadn't
> seen before. The author used a <<- operator to update a variable, like so:
> ecov_xy <<- ecov_xy+decay*(x[t]*y[t]-ecov_xy)
> At first I thought it was a mistake and tried replacing it with the usual <-
> assignment operator, but I didn't get the same results. So what does the
> double arrow <<- operator do?

It is a "super assignment" operator, which means that the assignment is done in the global environment, rather than to a variable that is within a function and therefore may only have local scope.

This is covered a bit in "An Introduction To R":

and a bit more in:




It can be a bit hazardous to use, given the potential confusion over variable scoping issues, which is why <- and <<- may not be interchangeable as you are observing.

HTH, Marc Schwartz mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 21 Apr 2011 - 20:01:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Apr 2011 - 20:20:33 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive