-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathzzz.r
36 lines (31 loc) · 962 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
31
32
33
34
35
36
.onLoad <- function(libname, pkgname) {
op <- options()
op.dplyr <- list(
dplyr.show_progress = TRUE
)
toset <- !(names(op.dplyr) %in% names(op))
if (any(toset)) options(op.dplyr[toset])
invisible()
}
.onAttach <- function(libname, pkgname) {
setHook(packageEvent("plyr", "attach"), function(...) {
packageStartupMessage(rule())
packageStartupMessage(
"You have loaded plyr after dplyr - this is likely ",
"to cause problems.\nIf you need functions from both plyr and dplyr, ",
"please load plyr first, then dplyr:\nlibrary(plyr); library(dplyr)"
)
packageStartupMessage(rule())
})
}
.onDetach <- function(libpath) {
setHook(packageEvent("plyr", "attach"), NULL, "replace")
}
when_attached <- function(pkg, action) {
if (is_attached(pkg)) {
action
} else {
setHook(packageEvent(pkg, "attach"), function(...) action)
}
}
is_attached <- function(pkg) paste0("package:", pkg) %in% search()