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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With