-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathzzz.R
36 lines (28 loc) · 1.03 KB
/
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
.onAttach <- function(...) {
if (!interactive() || runif(1) > 0.1) return()
pkgs <- available.packages()
cran_version <-
pkgs %>%
extract("rfm", "Version") %>%
package_version()
local_version <- packageVersion("rfm")
behind_cran <- cran_version > local_version
tips <- c(
"Learn more about rfm at https://github.com/rsquaredacademy/rfm/.",
"Use suppressPackageStartupMessages() to eliminate package startup messages.",
"Need help getting started with regression models? Visit: https://www.rsquaredacademy.com",
"Check out our interactive app for quick data exploration. Visit: https://apps.rsquaredacademy.com/."
)
tip <- sample(tips, 1)
if (interactive()) {
if (behind_cran) {
msg <- c("A new version of rfm is available with bug fixes and new features.")
packageStartupMessage(msg, "\nWould you like to install it?")
if (menu(c("Yes", "No")) == 1) {
update.packages("rfm")
}
} else {
packageStartupMessage(paste(strwrap(tip), collapse = "\n"))
}
}
}