Skip to main content

Expressions and Environments

  • Chapter
  • First Online:
Metaprogramming in R
  • 2218 Accesses

Abstract

This chapter digs deeper into how environments work and how you can evaluate expressions in different environments. Understanding how environments are chained together helps you understand how the language finds variables, and being able to create, manipulate, and chain together environments when evaluating expressions is a key trick for metaprogramming.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 44.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.

    If you want to name your environments, you can set the attribute “name.” It is generally not something you need, though.

  2. 2.

    Strictly speaking, there is a lot more to importing other packages than what I just explained here, but it’s beyond the scope of this book.

  3. 3.

    If you check the documentation for new.env, you will see that the default argument is actually parent.frame(). If you think about it, this is how it becomes the current environment: when you call new.env, the current environment will be its parent frame.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Thomas Mailund

About this chapter

Cite this chapter

Mailund, T. (2017). Expressions and Environments. In: Metaprogramming in R. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-2881-4_3

Download citation

Publish with us

Policies and ethics