forked from jrnold/r4ds-exercise-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_common.R
59 lines (51 loc) · 1.15 KB
/
_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
set.seed(1014)
options(digits = 3)
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
cache = TRUE,
autodep = TRUE,
# need to save cache
cache.extra = knitr::rand_seed,
out.width = "70%",
fig.align = "center",
fig.width = 6,
fig.asp = 0.618, # 1 / phi
fig.show = "hold",
# styler
tidy = 'styler'
)
options(dplyr.print_min = 6, dplyr.print_max = 6)
is_html <- knitr::opts_knit$get("rmarkdown.pandoc.to") == "html"
# Info and useful links
SOURCE_URL <- stringr::str_c("https:/", "github.com", "jrnold",
"r4ds-exercise-solutions",
sep = "/"
)
PUB_URL <- stringr::str_c("https:/", "jrnold.github.io",
"r4ds-exercise-solutions",
sep = "/"
)
R4DS_URL <- "https://r4ds.had.co.nz"
r4ds_url <- function(...) {
stringr::str_c(R4DS_URL, ..., sep = "/")
}
comma_int <- function(x) {
prettyNum(x, big.interval = 3, big.mark = ",")
}
no_exercises <- function() {
tags <- htmltools::tags
tags$div(
class = 'alert alert-warning hints-alert',
tags$div(
class = "hints-icon",
tags$i(
class = "fa fa-exclamation-circle"
)
),
tags$div(
class = "hints-container",
"No exercises"
)
)
}