r4ds/_common.R

54 lines
1.3 KiB
R
Raw Normal View History

set.seed(1014)
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
2021-04-20 19:48:01 +08:00
# cache = TRUE,
2022-02-24 04:05:33 +08:00
fig.retina = 2,
2016-07-18 22:52:55 +08:00
fig.width = 6,
2022-02-24 04:05:33 +08:00
fig.asp = 2/3,
2016-07-18 22:52:55 +08:00
fig.show = "hold"
)
2022-10-05 06:34:34 +08:00
options(
dplyr.print_min = 6,
dplyr.print_max = 6,
pillar.max_footer_lines = 2,
2023-01-24 23:33:18 +08:00
pillar.min_chars = 15,
stringr.view_n = 6,
# Activate crayon output - temporarily disabled for quarto
# crayon.enabled = TRUE,
pillar.bold = TRUE,
width = 77 # 80 - 3 for #> comment
2021-04-20 19:48:01 +08:00
)
2021-05-04 21:10:39 +08:00
2022-03-21 22:32:46 +08:00
ggplot2::theme_set(ggplot2::theme_gray(12))
2021-05-04 21:10:39 +08:00
status <- function(type) {
status <- switch(type,
2022-02-16 01:59:19 +08:00
polishing = "should be readable but is currently undergoing final polishing",
restructuring = "is undergoing heavy restructuring and may be confusing or incomplete",
drafting = "is currently a dumping ground for ideas, and we don't recommend reading it",
2022-05-03 21:35:39 +08:00
complete = "is largely complete and just needs final proof reading",
2021-05-04 21:10:39 +08:00
stop("Invalid `type`", call. = FALSE)
)
class <- switch(type,
polishing = "note",
restructuring = "important",
drafting = "important",
complete = "note"
)
2021-05-04 21:10:39 +08:00
cat(paste0(
2022-11-19 01:55:22 +08:00
"\n",
":::: status\n",
"::: callout-", class, " \n",
2021-05-04 21:10:39 +08:00
"You are reading the work-in-progress second edition of R for Data Science. ",
2022-02-16 01:59:19 +08:00
"This chapter ", status, ". ",
2022-04-27 21:01:00 +08:00
"You can find the complete first edition at <https://r4ds.had.co.nz>.\n",
2022-11-19 01:55:22 +08:00
":::\n",
"::::\n"
2021-05-04 21:10:39 +08:00
))
}