Gabor Csardi
banner
gaborcsardi.org
Gabor Csardi
@gaborcsardi.org
This is a way to tell if a non-base package is loaded:
invisible(lapply(loadedNamespaces(), function(x) stopifnot(identical(packageDescription(x)$Priority, "base"))))
September 27, 2025 at 6:03 PM
You can tell user to run the script from the command line, non-interactively, that makes things more predictable, but of course they might still need to have a custom R profile that loads packages or sets options, etc.
September 26, 2025 at 1:43 PM
Are you worried about packages that change the script's behavior? Or custom options? Or something else? You can check if any non-base package is loaded, but what if a user loads a package from their profile? Users also need to set custom options sometimes, e.g. for a http proxy.
September 26, 2025 at 1:40 PM
Hah, that example should be updated to something like this, which I now use for every custom print method:
```
generic_print <- function(x, ...) {
writeLines(format(x, ...))
invisible(x)
}
```

and then

```
#' @export
print.someclass <- generic_print
```
August 15, 2025 at 10:14 PM