An alias for rm(list = ls()) for a specified environment. Use with care.

clear(envir = globalenv())

Arguments

envir

an environment from which all objects will be removed. Default is .GlobalEnv (i.e. ''the user's workspace'').

Examples

x <- 1 y <- 2 x <- 3 ls()
#> [1] "x" "y"
clear()
#> Removing all objects from R_GlobalEnv
ls()
#> [1] "x" "y"