October 2011
Beginner to intermediate
400 pages
9h 30m
English
Most R objects are immutable, or unchangeable. Thus, R operations are implemented as functions that reassign to the given object, a trait that can have performance implications.
As an example of some of the issues that can arise, consider this simple-looking statement:
z[3] <- 8
As noted in Chapter 7, this assignment is more complex than it seems. It is actually implemented via the replacement function "[<-" through this call and assignment:
z <- "[<-"(z,3,value=8)
An internal copy of z is made, element 3 of the copy is changed to 8, and then the resulting vector is reassigned to z. And recall that the latter simply means that z is pointed to the copy.
In other words, even though we ...
Read now
Unlock full access