s3_register | R Documentation |
Code copied into data.tree from 'vctrs' (authors Wickham H, Henry L, Vaughan D; https://github.com/r-lib/vctrs)
s3_register(generic, class, method = NULL)
generic |
Name of the generic in the form 'pkg::generic'. |
class |
Name of the class |
method |
Optionally, the implementation of the method. By default, this will be found by looking for a function called 'generic.class' in the package environment. Note that providing 'method' can be dangerous if you use devtools. When the namespace of the method is reloaded by 'devtools::load_all()', the function will keep inheriting from the old namespace. This might cause crashes because of dangling '.Call()' pointers. |
For R 3.5.0 and later, 's3_register()' is useful when demonstrating class creation in a vignette, since method lookup no longer always involves the lexical scope. For R 3.6.0 and later, you can achieve a similar effect by using "delayed method registration".
# A typical use case is to dynamically register tibble/pillar methods
# for your class. That way you avoid creating a hard depedency on packages
# that are not essential, while still providing finer control over
# printing when they are used.
.onLoad <- function(...) {
s3_register("pillar::pillar_shaft", "vctrs_vctr")
s3_register("tibble::type_sum", "vctrs_vctr")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.