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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.