Skip to main content

Immutable and Persistent Data

  • Chapter
  • First Online:
Functional Data Structures in R
  • 2148 Accesses

Abstract

What prevents us from implementing traditional imperative-language data structures in R is the immutability of data. As a general rule, you can modify environments—so you can assign to variables—but you cannot modify actual data. Whenever R makes it look like you are changing data, it is lying.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 19.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 29.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Strictly speaking, we can create side effects that affect data structures—we just have to modify environments. The reference class system, R6, emulates objects with a mutable state by updating environments, and we can do the same via closures. When we get to Chapter 4, where we will implement queues, I’ll introduce side effects of member queries, and there we will use this trick. Unless we represent all data structures by collections of environments, though, the method only gets us so far. We still need to build data structures without modifying data—we just get to remember the result in an environment we constructed for this purpose.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Thomas Mailund

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Mailund, T. (2017). Immutable and Persistent Data. In: Functional Data Structures in R. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3144-9_3

Download citation

Publish with us

Policies and ethics