Both are used, just in different contexts. If we don't use them in the right contexts, we'll see errors. See here:
Using <- is for defining a local variable.
#Example: creating a vector
x <- c(1,2,3)
#Here we could use = and that would happen to work in this case.
Using <<- , as Joshua Ulrich says, searches the parent environments "for an existing definition of the variable being assigned." It assigns to the global environment if no parent environments contain the variable.
#Example: saving information calculated in a function
x <- list()
this.function <– function(data){
...misc calculations...
x[[1]] <<- result
}
#Here we can't use ==; that would not work.
Using = is to state how we are using something in an argument/function.
#Example: plotting an existing vector (defining it first)
first_col <- c(1,2,3)
second_col <- c(1,2,3)
plot(x=first_col, y=second_col)
#Example: plotting a vector within the scope of the function 'plot'
plot(x<-c(1,2,3), y<-c(1,2,3))
#The first case is preferable and can lead to fewer errors.
Then we use == if we're asking if one thing is equal to another, like this:
#Example: check if contents of x match those in y:
x <- c(1,2,3)
y <- c(1,2,3)
x==y
[1] TRUE TRUE TRUE
#Here we can't use <- or =; that would not work.