I am reading Hadley's Advanced R. In chapter 8, he says that we can remove an object from an environment by using rm()
. However, I am still able to see the object after removing it.
Here's my code:
e<- new.env()
e$a<-1
e$b<-2
e$.a<-3
e$c<-4
ls(e,all.names = TRUE)
#remove the object c
rm("c",envir = e)
ls(e,all.names = TRUE) #Doesn't exist here
#does the variable exist?
exists("c",envir = e) #Shows TRUE. Why is this?
exists("m",envir = e) #FALSE
ls(e,all.names = TRUE)
ls(e)
As we can see above, ideally, I'd have expected exists("c", envir = e)
to return FALSE
.
Any thoughts? Thanks in advance.