-
-
Notifications
You must be signed in to change notification settings - Fork 969
/
zzz.R
31 lines (29 loc) · 898 Bytes
/
zzz.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.onLoad <- function(lib, pkg) {
.render_context <<- new_stack()
if (getOption("rmarkdown.df_print", TRUE)) {
registerMethods(list(
# c(package, genname, class)
c("knitr", "knit_print", "data.frame")
))
}
}
# Reusable function for registering a set of methods with S3 manually. The
# methods argument is a list of character vectors, each of which has the form
# c(package, genname, class).
registerMethods <- function(methods) {
lapply(methods, function(method) {
pkg <- method[[1]]
generic <- method[[2]]
class <- method[[3]]
func <- get(paste(generic, class, sep = "."))
if (pkg %in% loadedNamespaces()) {
registerS3method(generic, class, func, envir = asNamespace(pkg))
}
setHook(
packageEvent(pkg, "onLoad"),
function(...) {
registerS3method(generic, class, func, envir = asNamespace(pkg))
}
)
})
}