rm(list=ls()) doesn't completely clear the workspace

Viewed 86080

This is a very minor issue, but I would like to understand exactly what is going on here.

Say I do the following:

library(RMySQL)
con <- dbConnect(MySQL(), host="some.server.us-east-1.rds.amazonaws.com",user="aUser", password="password", dbname="mydb")

values1 <- dbGetQuery(con,"select x,y from table1")
attach(values1)

At this point, I can do

rm(list=ls())

values2 <- dbGetQuery("select x,y from table1")
attach(values2)

but the attach gives me a warning about masking an x and y. I thought I had already clobbered those. What is going on? How do I completely clear a workspace?

7 Answers

if you are working with RStudio, you can just go to Session->Clear Workspace... To clear all variables from your workspace

Related