-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupport.R
More file actions
48 lines (45 loc) · 1.07 KB
/
support.R
File metadata and controls
48 lines (45 loc) · 1.07 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
43
44
45
46
47
48
## Common support code for vignettes. This will not be echoed to the
## user, so be sure not to define functions here that they might want
## to use.
##
## Typically, include this in the Rmd within a block like:
##
## ```{r, include = FALSE}
## ...
## ```
dir_tree <- function(path = ".", sub = ".", all = FALSE,
ignore_outpack = TRUE, ...) {
if (all && ignore_outpack) {
regexp <- "^\\.outpack"
invert <- TRUE
} else {
regexp <- NULL
invert <- FALSE
}
withr::with_dir(
path,
fs::dir_tree(sub, all = all, regexp = regexp, invert = invert, ...))
}
lang_output <- function(x, lang) {
writeLines(c(sprintf("```%s", lang), x, "```"))
}
r_output <- function(x) {
lang_output(x, "r")
}
yaml_output <- function(x) {
lang_output(x, "yaml")
}
json_output <- function(x) {
lang_output(x, "json")
}
plain_output <- function(x) {
lang_output(x, "plain")
}
orderly_file <- function(...) {
system.file(..., package = "orderly", mustWork = TRUE)
}
inline <- function(x) {
sprintf("`%s`", format(x))
}
knitr::opts_chunk$set(
collapse = TRUE)