dbosak01 / libr

An R package to create data libraries and data dictionaries.
27 stars 1 forks source link

Within function environment #30

Closed dbosak01 closed 3 years ago

dbosak01 commented 3 years ago

Withing a function, libr should use the environment of the function, and not the global environment. That means each call to libname has to capture the parent environment, and use that on all subsequent calls. Will have to track the scope for each libname.

dbosak01 commented 3 years ago

Set environment to parent.frame() on call to libname function. Seems to be resetting the environment for different environments: global or within a function. Much better than previous method. Previously, it was always going to the global environment, so that if you wanted to set a data frame with . you had to reference the global environment. Within a function, this was not good, and totally not intuitive when it didn't work. Confused me for hours. Now it just takes the parent environment, whatever that is, and uses it for for any subsequent calls. Honestly now sure why it is working. But it is, and I'll go with it for now. More testing required, however, and I'll probably push back the release date to test more.