Hello,

Currently `use` fails silently if you try to attach functions from the same namespace. It would be nice and more similiar to the use of roxygen2 if it could add (and maybe even remove?) functions. Here is a simple proof of concept I have posted on Stack Overflow [1]. Something similar could be done within `use`. Of course, it would be preferable if it didn't need to detach the namespace.

|use("data.table", "fread") ls("package:data.table") #[1] "fread" use("data.table", "nafill") ls("package:data.table") #[1] "fread" useplus <- function(package, include.only) { loaded <- ls(sprintf("package:%s", package), all.names = TRUE) unloadNamespace(package) if (missing(include.only)) { use(package) } else { use(package, union(loaded, include.only)) } } useplus("data.table", "nafill") ls("package:data.table") #[1] "fread" "nafill"|


[1] https://stackoverflow.com/q/79633064/1412059

--
Dr. Roland Fuß

Thünen-Institut für Agrarklimaschutz/
Thünen Institute of Climate-Smart Agriculture

Bundesallee 65
D-38116 Braunschweig, Germany

Tel./Webex: ++49 531 25701967
Email: [email protected]

Arbeitsgruppe "Emissionsberichterstattung"/
Working group "Emission Inventories"
Email: [email protected]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to