KentonWhite / ProjectTemplate

A template utility for R projects that provides a skeletal project.
http://projecttemplate.net
GNU General Public License v3.0
622 stars 159 forks source link

Remove dot variables in global env when clear() is run #173

Closed connectedblue closed 7 years ago

connectedblue commented 7 years ago

This PR enables all variables to be removed from the global environment by clear() including those beginning with a dot (except if they are protected by config$sticky_vars).

This assists with some hard-to-track bugs where there is a .variable in global env that conflicts with something in a package, and the package value is masked by precedence. You can't necessarily see these variables by default using ls(). Also, if you use RStudio, it saves a snapshot of global env across restarts perpetuating the problem.

I'm pretty sure this happened to me when working on #163. Tests passed on my local machine but not travis - I was missing a function .var.diff.from in the package which was being masked because it was lurking in the global environment.

I added a small documentation update on the man page and also some regression tests.

Hugovdberg commented 7 years ago

I get a failure on the test:

1. Failure: running clear() removes variables beginning with a dot (except the config$sticky_variables) (@test-clear.R#218) -----------------------------------------------------------------------
`messages` does not match "clear from memory: .xxx".
Actual value: "Objects to clear from memory: config .xxx\n"
KentonWhite commented 7 years ago

@Hugovdberg Is this test failure still happening? Did you find the cause or fix?