The idea of ββthe environment is important, and you use it all the time, mostly without being aware of it. If you just use R and donβt do anything interesting, indirect use of the environment is all you need and you donβt need to explicitly create and manage environments. Only when you switch to more advanced use will you need to understand more. The main place that you use (indirectly) is that each function has its own environment, so every time you run the function, you use new environments. Why is this important because it means that if the function uses a variable named "x" and you have a variable named "x", then the computer can support them directly and use the correct one when necessary, and your copy is "x "msgstr" is not overwritten by the version of functions.
Some other cases where you can use environments: each package has its own environment, so 2 packages can be loaded with the same name of the internal function, and they will not interfere with each other. You can keep your workspace a little cleaner by adding new definitions of the environment and load functions to this environment rather than to the global or work environment. When you write your own functions and want to share variables between functions, you will need to understand the environments. Environmets can be used to emulate pass-by-reference instead of pass-by-value, if you have ever been in a situation where it matters (if you do not recognize these phrases, then it probably does not matter).
source share