-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.R
55 lines (40 loc) · 1.33 KB
/
setup.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# A polite helper for installing packages ---------------------------------
please_install <- function(pkgs, install_fun = install.packages) {
if (length(pkgs) == 0) {
return(invisible())
}
if (!interactive()) {
stop("Please run in interactive session", call. = FALSE)
}
title <- paste0(
"Ok to install these packges?\n",
paste("* ", pkgs, collapse = "\n")
)
ok <- menu(c("Yes", "No"), title = title) == 1
if (!ok) {
return(invisible())
}
install_fun(pkgs)
}
# Do you have all the needed packages? ------------------------------------
tidytools <- c(
"usethis", "rlang", "devtools", "tidyverse", "fs",
"rstudioapi"
)
have <- rownames(installed.packages())
needed <- setdiff(tidytools, have)
please_install(needed)
# lobstr ------------------------------------------------------------------
if (!"lobstr" %in% have) {
please_install("hadley/lobstr", devtools::install_github)
}
# Do you have the latest ggplot2 ? ----------------------------------------
# It was updated recently so if you've used it before you might
# have an old version
if (packageVersion("ggplot2") < "3.0.0") {
please_install("ggplot2")
}
# Do you have the latest RStudio? ---------------------------------------
if (rstudioapi::getVersion() < "1.1.419") {
cat("Please install RStudio from http://rstd.io/download-ide\n")
}