Skip to content

Commit 80641db

Browse files
committed
update example files
1 parent 72a46d6 commit 80641db

24 files changed

+83
-5178
lines changed

R/add_to_gitignore.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ add_to_gitignore <- function(add.to.gitignore = FALSE, cutoff = NULL, extension
3535
# ensure the path is in the correct format for your system
3636
path <- normalizePath(path)
3737

38-
print("asasd")
39-
4038
if (is.null(cutoff) & is.null(extension))
4139
.stop("'cutoff' and/or 'extension' must be supplied")
4240

R/make_compendium.R

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#' @param name character string: the research compendium directory name. No special characters should be used. Default is "research_compendium".
88
#' @param path Path to put the project directory in. Default is current directory.
99
#' @param force Logical controlling whether existing folders with the same name are used for setting the folder structure. The function will never overwrite existing files or folders.
10-
#' @param format A character vector of length 1 with the name of the built-in compendiums available in the example object `compendiums` (see \code{\link{compendiums}} for available formats). Default is 'basic'. Alternatively, it can be a character vector with 2 or more elements with the names of the folders and subfolders to be included.
10+
#' @param format A character vector of length 1 with the name of the built-in compendiums available in the example object `compendiums` (see \code{\link{compendiums}} for available formats). Default is 'basic'. Alternatively, it can be a character vector with 2 or more elements with the names of the folders and subfolders to be included (e.g. \code{c("folder_1", "folder_1/subfolder_1", "folder_1/subfolder_2")}).
1111
#' @param packrat Logical to control if packrat is initialized (\code{packrat::init()}) when creating the compendium. Default is \code{FALSE}.
1212
#' @param git Logical to control if a git repository is initialized (\code{git2r::init()}) when creating the compendium. Default is \code{FALSE}.
1313
#' @param clone Path to a directory containing a folder structure to be cloned. Default is \code{NULL}. If provided 'format' is ignored. Folders starting with \code{^\\.git|^\.Rproj.user|^\\.\\.Rcheck} will be ignored.
@@ -21,8 +21,14 @@
2121
#' @examples {
2222
#' data(compendiums)
2323
#'
24-
#'make_compendium(name = "mycompendium", path = tempdir(), format = "basic",
24+
#' # default format
25+
#' make_compendium(name = "mycompendium", path = tempdir(), format = "basic",
2526
#' force = TRUE)
27+
#'
28+
#' # custom format
29+
#' make_compendium(name = "my_second_compendium", path = tempdir(),
30+
#' format = c("folder_1", "folder_1/subfolder_1", "folder_1/subfolder_2"),
31+
#' force = TRUE)
2632
#' }
2733
#'
2834
#' @author Marcelo Araya-Salas (\email{marcelo.araya@@ucr.ac.cr})
@@ -190,10 +196,13 @@ make_compendium <-
190196
ignore.case = TRUE,
191197
value = TRUE
192198
)[1],
193-
"analysis_template.Rmd"
194-
)))
199+
"analysis_template_rmarkdown.Rmd"
200+
))){
201+
rmarkdown_template <- internal_files$analysis_template_rmarkdown
202+
rmarkdown_template[3] <- paste("subtitle:", name)
203+
195204
writeLines(
196-
internal_files$analysis_template,
205+
rmarkdown_template,
197206
file.path(
198207
path,
199208
name,
@@ -203,9 +212,10 @@ make_compendium <-
203212
ignore.case = TRUE,
204213
value = TRUE
205214
)[1],
206-
"analysis_template.Rmd"
215+
"analysis_template_rmarkdown.Rmd"
207216
)
208217
)
218+
}
209219

210220
# save analysis template in quarto format
211221
if (!file.exists(file.path(
@@ -218,9 +228,13 @@ make_compendium <-
218228
value = TRUE
219229
)[1],
220230
"analysis_template_quarto.qmd"
221-
)))
231+
))){
232+
# change subtitle
233+
quarto_template <- internal_files$analysis_template_quarto
234+
quarto_template[3] <- paste("subtitle:", name)
235+
222236
writeLines(
223-
internal_files$analysis_template_quarto,
237+
quarto_template,
224238
file.path(
225239
path,
226240
name,
@@ -233,7 +247,7 @@ make_compendium <-
233247
"analysis_template_quarto.qmd"
234248
)
235249
)
236-
250+
}
237251
# save rmd.css
238252
if (!file.exists(file.path(
239253
path,

R/print_skeleton.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#' @references {
2323
#' Araya-Salas, M., Arriaga, A. (2023), sketchy: research compendiums for data analysis in R. R package version 1.0.3.
2424
#' }
25-
#last modification on dec-26-2019 (MAS)
2625

2726
print_skeleton <- function(path = ".", comments = NULL, folders = NULL)
2827
{

R/sysdata.rda

217 Bytes
Binary file not shown.

examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.quarto/

examples/analysis_template_quarto.qmd

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ subtitle: A very fancy project
44
author: <a href="http://researcher.website.com/">Researcher name</a>
55
date: "`r Sys.Date()`"
66
toc: true
7-
toc-depth: 2
7+
toc-depth: 3
88
toc-location: left
99
number-sections: true
1010
highlight-style: pygments
@@ -14,6 +14,8 @@ format:
1414
code-fold: show
1515
code-tools: true
1616
css: qmd.css
17+
editor_options:
18+
chunk_output_type: console
1719
---
1820

1921
```{r set root directory}
@@ -28,12 +30,14 @@ knitr::opts_knit$set(root.dir = "..")
2830
```{r add link to github repo}
2931
#| eval: true
3032
#| output: asis
33+
#| echo: false
3134
3235
# print link to github repo if any
3336
if (file.exists("./.git/config")){
3437
config <- readLines("./.git/config")
3538
url <- grep("url", config, value = TRUE)
3639
url <- gsub("\\turl = |.git$", "", url)
40+
if (nchar(url) > 1)
3741
cat("\nSource code and data found at [", url, "](", url, ")", sep = "")
3842
}
3943
@@ -52,37 +56,33 @@ knitr::opts_chunk$set(
5256
5357
```
5458

55-
5659
<!-- skyblue box -->
5760

5861
::: {.alert .alert-info}
59-
6062
# Purpose {.unnumbered .unlisted}
6163

62-
- The first goal of this report
63-
64-
- The second goal of this report
64+
- The first goal of this report
6565

66+
- The second goal of this report
6667
:::
6768

68-
&nbsp;
69-
69+
 
7070

7171
<!-- light brown box -->
72-
::: {.alert .alert-warning}
7372

73+
::: {.alert .alert-warning}
7474
# Report overview {.unnumbered .unlisted}
7575

76-
- You can have the sections listed here, for instance:
77-
78-
- [Lorem ipsum](#lorem-ipsum)
79-
- [Takeaways](#takeaways)
76+
- You can have the sections listed here, for instance:
8077

78+
- [Lorem ipsum](#lorem-ipsum)
79+
- [Takeaways](#takeaways)
8180
:::
8281

83-
&nbsp;
82+
 
8483

8584
# Analysis flowchart {.unnumbered .unlisted}
85+
8686
```{mermaid}
8787
8888
flowchart
@@ -91,14 +91,13 @@ flowchart
9191
C --> D(Statistical analysis)
9292
D --> E(Model summary)
9393
94-
style A fill:#44015466
95-
style B fill:#3E4A894D
96-
style C fill:#26828E4D
97-
style D fill:#6DCD594D
94+
style A fill:#382A5433
95+
style B fill:#395D9C33
96+
style C fill:#3497A933
97+
style D fill:#60CEAC33
9898
9999
```
100100

101-
102101
# Load packages {.unnumbered .unlisted}
103102

104103
```{r load packages}
@@ -119,9 +118,9 @@ a <- 1
119118
b <- 2
120119
```
121120

122-
# Lorem ipsum
121+
# Lorem ipsum {#lorem-ipsum}
123122

124-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in felis ut mauris consectetur sodales. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse nec ex neque. Nunc ultricies et ante ac feugiat. Nulla quam ex, viverra eget mollis non, porttitor nec ante. Donec non felis a nisi elementum consectetur tempor in mauris. Curabitur leo nunc, posuere in erat sit amet, varius aliquam mi. Nullam lacinia odio neque, et semper erat fermentum ut. Praesent mi massa, convallis in vehicula mattis, condimentum ac risus. In eget metus eget nunc pulvinar finibus. Proin nec tellus sed lorem malesuada aliquet sed laoreet augue.
123+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in felis ut mauris consectetur sodales. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse nec ex neque. Nunc ultricies et ante ac feugiat. Nulla quam ex, viverra eget mollis non, porttitor nec ante. Donec non felis a nisi elementum consectetur tempor in mauris. Curabitur leo nunc, posuere in erat sit amet, varius aliquam mi. Nullam lacinia odio neque, et semper erat fermentum ut. Praesent mi massa, convallis in vehicula mattis, condimentum ac risus. In eget metus eget nunc pulvinar finibus. Proin nec tellus sed lorem malesuada aliquet sed laoreet augue.
125124

126125
```{r example external image}
127126
#| eval: true
@@ -137,32 +136,37 @@ knitr::include_graphics("https://www.r-project.org/logo/Rlogo.svg")
137136

138137
<!-- '&nbsp;' adds blank space -->
139138

140-
141-
142139
<!-- light green box -->
143140

144141
::: {.alert .alert-success}
145-
146-
# Takeaways {.unnumbered .unlisted}
142+
# Takeaways {#takeaways .unnumbered .unlisted}
147143

148144
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in felis ut mauris consectetur sodales. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
145+
:::
149146

150-
:::
151-
152-
&nbsp;
147+
 
153148

154149
<!-- '---' adds a gray vertical line -->
155150

156-
---
151+
------------------------------------------------------------------------
152+
153+
 
154+
155+
<!-- add packages used, system details and versions -->
157156

158-
&nbsp;
159-
160-
<!-- add packages used, system details and versions -->
161-
162157
# Session information {.unnumbered .unlisted}
163158

164-
```{r session info, echo=F}
159+
<details>
160+
<summary>Click to see</summary>
161+
```{r session info}
162+
#| echo: false
165163
166-
sessionInfo()
164+
# if devtools is installed use devtools::session_info()
165+
if (requireNamespace("devtools", quietly = TRUE)) {
166+
devtools::session_info()
167+
} else {
168+
sessionInfo()
169+
}
167170
168171
```
172+
</details>

0 commit comments

Comments
 (0)