Reputation: 6615
If I am using a dataset that comes supplied in a package and I accidentally edit it and overwrite some values, how can I restore it back to its original form? Is there a command for this other than unloading the package?
Upvotes: 5
Views: 6030
Reputation: 5494
Just delete the variable:
library("ISwR")
typeof(alkfos) # list
alkfos <- 3
typeof(alkfos) # double
rm(alkfos)
typeof(alkfos) # list
This works because of the way R environments are set up: your R_GlobalEnv environment ("global variable environment") is hiding the variables in the library, but they aren't overwritten. Once you clear the variable with the colliding name from your GlobalEnv, the library is again the default result of evaluating that name.
Upvotes: 10