tags:

views:

121

answers:

1

I know nothing about R, when I read a R code, in the very first line, there appears

rm(list=ls())

What does it mean? Thanks

+4  A: 

ls() in R lists the active variables and rm(list=ls()) will remove all the active variables.

Andriyev
@serina you could say as well, that `rm (list = ls())` will remove all the objects in the current environment. it is a `kill all` command. so be a bit careful with it. btw, just read the nicely written R help files, in this case `?rm` and `?ls`
mropa
Cool things like this can also be done: `rm(list=ls(pattern='^a.+'))`
Vince
Vince, thanks for stressing that one, you can use partial matching `ls(pat = "<someregexp>")`, mropa, actually, `rm(list=ls())` doesn't delete ALL object in .GlobalEnv, but only the visible ones. Objects with .Names are omitted. If you want to delete all objects, run `rm(list = ls(all.names = TRUE))`.
aL3xa