Displaying 2 results from an estimated 2 matches for "modify_attach".
2024 Apr 15
1
[External] Re: Repeated library() of one package with different include.only= entries
...with a new include.only specification.
> This is the "quite hard to accomplish" I alluded to, admittedly I hadn't
> forced myself to write it all out -- maybe it's not as bad as all that.
> After some iterations, today I think we'd want to do...
> modify_attach <- function(pkg, new_names) {
> if (!startsWith(pkg, "package:")) pkg <- paste0("package:", pkg)
> old <- tryCatch(ls(pkg, all.names=TRUE), error=\(c) character())
> if (length(old)) detach(pkg)
> attachNamespace(.rmpkg(pkg), include....
2024 Apr 11
1
[External] Re: Repeated library() of one package with different include.only= entries
...library() or
> attachNamespace() with a new include.only specification.
This is the "quite hard to accomplish" I alluded to, admittedly I hadn't
forced myself to write it all out -- maybe it's not as bad as all that.
After some iterations, today I think we'd want to do...
modify_attach = function(pkg, new_names) {
if (!startsWith(pkg, "package:")) pkg <- paste0("package:", pkg)
old <- tryCatch(ls(pkg, all.names=TRUE), error=\(c) character())
if (length(old)) detach(pkg)
attachNamespace(.rmpkg(pkg), include.only=c(new_names, old))
}
Perhaps detac...