-
Notifications
You must be signed in to change notification settings - Fork 14
/
common.R
38 lines (35 loc) · 970 Bytes
/
common.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
print(here::here())
knitr::opts_chunk$set(
digits = 3,
comment = "#>",
dev = 'svglite',
dev.args = list(bg = "transparent"),
fig.path = "figs/",
fig.align = "center",
collapse = TRUE
)
options(width = 80, cli.width = 70)
article_req_pkgs <- function(x, what = "To use code in this article, ") {
x <- sort(x)
x <- knitr::combine_words(x, and = " and ")
paste0(
what,
" you will need to install the following packages: ",
x, "."
)
}
small_session <- function(pkgs = NULL) {
pkgs <- c(pkgs, "recipes", "parsnip", "tune", "workflows", "dials", "dplyr",
"broom", "ggplot2", "purrr", "rlang", "rsample", "tibble", "infer",
"yardstick", "tidymodels", "infer")
pkgs <- unique(pkgs)
library(sessioninfo)
library(dplyr)
sinfo <- sessioninfo::session_info()
cls <- class(sinfo$packages)
sinfo$packages <-
sinfo$packages %>%
dplyr::filter(package %in% pkgs)
class(sinfo$packages) <- cls
sinfo
}