To remove a variable or function from the environment in R, you need to use the rm()
function.
Syntax:
main.r16 chars2 lines
Here object_name
is the name of the variable or function that you want to remove.
Example:
Let's say we have a variable x
in our environment that we want to remove:
main.r8 chars2 lines
We can remove it using the rm()
function as follows:
main.r6 chars2 lines
Now, if we try to access x
, we will get an error message saying that object 'x' not found
.
Note: If you want to remove multiple objects at once, you can provide their names as a vector to the rm()
function. For example:
main.r12 chars2 lines
This will remove the variables x
, y
, and z
from the environment.
gistlibby LogSnag