Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amend description for "madrat-based packages" #221

Open
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q opened this issue Oct 16, 2024 · 0 comments
Open
Assignees

Comments

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q
Copy link
Member

madrat/vignettes/madrat.Rmd

Lines 174 to 196 in d664da2

### Create madrat-based package
Since version 1.00 madrat allows to link packages to it and make use of its functionality. For linking madrat (in version >= 2.5.1) has to be added as a package dependency.
```
Depends: madrat(>= 2.5.1)
```
In addition the following lines of code should be added as `madrat.R` to the R folder of the package.
```{r, eval = FALSE}
.onAttach <- function(libname, pkgname) {
madrat::madratAttach(pkgname)
}
.onDetach <- function(libpath) {
madrat::madratDetach(libpath)
}
```
The `.onAttach` statement makes sure that the package is linked to madrat as soon as it is loaded. The replacements of `cat`, `message`, `warning` and `stop`are required to make use of the specific notification system in madrat, which makes for instance sure that all notes, warnings and error messages will show up in the written log files.
Besides these modifications no further changes are required and functions in the new package will be visible to the `madrat` wrapper functions.

  • The .onAttach statement makes sure that the package is linked to madrat as soon as it is loaded.

    This is not correct. Packages are linked to madrat only when their namespace is attached to the search path, (i.e. declared as a Depends dependency), not when they are loaded (declared as a Imports dependency).

  • There is no documentation that other madrat-based packages must be declared as Depends dependencies in order to be registered with madrat. See discussion in madrat caching dependent on attached packages #219.

  • The replacements of cat, message, warning and stop are required to make use of the specific notification system in madrat, which makes for instance sure that all notes, warnings and error messages will show up in the written log files.

    Should include example code, then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants