Maho Takahashi

Linguistics PhD Student at UC San Diego

research

CV

code

mtakahas[at]ucsd[dot]edu

How to remove variables

At the end of a long script, you might want to remove any temporary variables/variables that you won’t use. Here’s how you do so:

a = c(3,4,5)
b = c(6,7,8)
c = a+b

rm(list = setdiff(ls(), c("c")))

Now your environment only has the variable c. If you want to remove all variables from the environment, here’s how:

rm(list=ls())

Now your environment should be empty.