Skip to content
Prev 32013 / 398506 Next

<-

These are called `replacement functions', or sometimes `assignment
functions'.  Leaving aside S4 methods (set by setReplaceMethod), they all
end in "<-", as the first quoted example is actually evaluated as 
something very close to

x <- "substring<-"(x, 1, 1, toupper(substring(x, 1, 1)))

In the base package there are
[1] "$<-"                "<-"                 "<<-"
 [4] "[<-"                "[[<-"               "attr<-"
 [7] "attributes<-"       "body<-"             "class<-"
[10] "codes<-"            "colnames<-"         "comment<-"
[13] "contrasts<-"        "diag<-"             "dim<-"
[16] "dimnames<-"         "environment<-"      "formals<-"
[19] "is.na<-"            "length<-"           "levels<-"
[22] "mode<-"             "mostattributes<-"   "names<-"
[25] "oldClass<-"         "parent.env<-"       "row.names<-"
[28] "rownames<-"         "split.data.frame<-" "split<-"
[31] "storage.mode<-"     "substr<-"           "substring<-"
[34] "tsp<-"

(and some methods; "split.data.frame<-" is a mistake and codes<- is 
deprecated in R-devel).

But users can write them as well, and there are some in the methods 
package.
On Wed, 14 May 2003, Damon Wischik wrote: