import.gen wercker status codecov.io

Generate import calls.

Ever got bitten by conflicting symbols in the packages you attach via library()? The import package offers a solution by specifying exactly which symbols to load into a dedicated environment, instead of attaching the whole package to the search path. But what if you actually want all (or almost all) symbols from a package?

devtools::load_all(".")
import.gen::from("magrittr", "tidyr", .output = "cat")

By default, the generated code is copied to the clipboard so that the developer can paste it at the appropriate place right away.

But what's the difference to library() then? The autogenerated import::from calls will continue working even if a package that has been imported from introduces a new conflicting symbol. In the example above, imagine tidyr adds a set_names function. Attaching magrittr and then tidyr will overwrite the set_names function, which will probably break code that used this function. In contrast, the import declaration remains unchanged unless we choose to rerun the import.gen::from call.

The package is at a very early stage but should work as advertised above. It uses the clipr package by Matthew Lincoln. Install the package via:

devtools::install_github("krlmlr/import.gen")


krlmlr/import.gen documentation built on May 20, 2019, 6:16 p.m.