-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstallpkgs.R
More file actions
executable file
·42 lines (37 loc) · 1.35 KB
/
installpkgs.R
File metadata and controls
executable file
·42 lines (37 loc) · 1.35 KB
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
#' Install packages if they're not already installed
#'
#' This is a tiny wrapper to just make sure that the necessary
#' packages are installed. We just want to make it easy to get the session
#' ready for the workshop, so we don't want to run any rework if the necessary
#' packages are already available.
#'
#' **Use with caution** - this is not a robust function. This is only intended
#' for use from a fresh slate like a new RStudio Cloud project. For example,
#' if a dependency of a package is missing but the package is installed, this
#' won't repair the missing dependency.
#'
#' @param pkgs
#'
#' @return NULL
#' @examples
#'
#' install_if_not(c('pharmaRTF', 'Tplyr'))
#'
install_if_not <- function(pkgs) {
# Filter the list down to anything not installed
pkgs <- pkgs[!(pkgs %in% installed.packages())]
if (length(pkgs) > 0) {
message('Installing the following packages:')
message(paste0("\t", pkgs, "\n"))
}
install.packages(pkgs)
}
install_if_not(
c('rmarkdown', 'Rcpp', 'rprojroot', 'tidyverse',
'magrittr', 'knitr', 'kableExtra', 'reticulate')
)
system('bash ./setup.sh')
# Set up Python for reticulate
# This path is using the miniconda installation, which is located
# inside of the home directory based on how the setup script installed it
reticulate::use_python("~/miniconda/bin/python3", required = TRUE)