In the first line, we are creating regular variable
a <- 13
And now, let's create environment variable.
b <- new.env()
If we use function ls(), we are going to receive list of all variables in our session, and we are going to see that both of this variables are present.
Where is the main difference in between regular and environment variables in R? With environment variables you can assign multiple values to a single variable.
b$first <- "value"
b$second <- 17
In this case, we have created two sub variables under environment variable b, and in order to use those sub-variables, we are going to call them from environment variable b like:
message(b$second)
So, in order to access value withing environment variable we are going to use environment variable name, then $ and sub-variable name at the end.
Finally, if we want to delete environment variable from our session, we can do that in the same way like with any regular variable.
rm( b)
For video tutorial, check the link below.
No comments:
Post a Comment