clearing enviroment in r

To clear all the objects from the environment in R, you can use the rm() function. Here's an example:

main.r
# Clear all objects from environment
rm(list = ls())
53 chars
3 lines

In this snippet, the ls() function returns a character vector of all the object names in the current environment. The list argument in the rm() function takes this vector as input and removes all the objects from the environment.

Note that this is a destructive action and cannot be undone. Use with caution.

related categories

gistlibby LogSnag