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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
If you want to name your environments, you can set the attribute “name.” It is generally not something you need, though.
- 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.
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
Rights 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
DOI: https://doi.org/10.1007/978-1-4842-2881-4_3
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-2880-7
Online ISBN: 978-1-4842-2881-4
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)