What in the world are by reference semantics?

In order to properly extol the virtues of setorder and understand the price we pay for it, we need to discuss what it means to modify a structure by reference as opposed to by value. This is a somewhat advanced topic but I feel that it is essential for (a) learning how data.table is so powerful and fast, and (b) preventing you, dear reader, from corrupting your data accidentally. In addition, the material in this discussion introduces concepts and terms in computer science that will serve you well to know for programming in other languages.

Most R programs use expressions that use by value semantics.

Here’s an example code.

Let’s make a two copies of mtcars, called mtcopy and mtcopy2, using the ...

Get Data Analysis with R - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.