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

前端 未结 7 1357
一向
一向 2020-12-08 04:36

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         


        
7条回答
  •  生来不讨喜
    2020-12-08 05:13

    Just to mention... if you, perhaps, have hidden objects in your environment, like .First and .Last functions, you can remove them with rm(list = ls(all.names = TRUE)). But in your case, use detach(objectname) to remove object from search path. detach() will remove any object in position #2, since .GlobalEnv cannot be removed (and base too). With detach() you can unload previously loaded packages, so be careful (though you can always load them with library(packagename)).

提交回复
热议问题