This will create a boilerplate directory structure for a Carpentries lesson and initialize a git repository.
Usage
create_lesson(
path,
name = fs::path_file(path),
rmd = TRUE,
rstudio = rstudioapi::isAvailable(),
open = rlang::is_interactive()
)
Arguments
- path
the path to the new lesson folder
- name
the name of the lesson. If not provided, the folder name will be used.
- rmd
logical indicator if the lesson should use R Markdown (
TRUE
, default), or if it should use Markdown (FALSE
). Note that lessons can be converted to use R Markdown at any time by adding a file with the.Rmd
file extension in the lesson.- rstudio
create an RStudio project (defaults to if RStudio exits)
- open
if interactive, the lesson will open in a new editor window.
Examples
tmp <- tempfile()
on.exit(unlink(tmp))
lsn <- create_lesson(tmp, name = "This Lesson", open = FALSE)
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
#> ℹ No schedule set, using Rmd files in episodes/ directory.
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
#> → To remove this message, define your schedule in config.yaml or use `set_episodes()` to generate it.
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
#> ────────────────────────────────────────────────────────────────────────
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
#> ℹ To save this configuration, use
#>
#> set_episodes(path = path, order = ep, write = TRUE)
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
#> • Edit '/tmp/RtmpyvAm1R/file18d27f04eb9e/episodes/introduction.Rmd'
#> ✔ First episode created in /tmp/RtmpyvAm1R/file18d27f04eb9e/episodes/introduction.Rmd
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
#> ℹ Workflows up-to-date!
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
#> ℹ Consent to use package cache provided
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
#> - The project is out-of-sync -- use `renv::status()` for details.
#> → Searching for and installing available dependencies
#> The following packages were discovered:
#>
#> # ~/work/_temp/Library -------------------------------------------------------
#> - R6 2.5.1
#> - base64enc 0.1-3
#> - bslib 0.6.0
#> - cachem 1.0.8
#> - cli 3.6.1
#> - digest 0.6.33
#> - ellipsis 0.3.2
#> - evaluate 0.23
#> - fastmap 1.1.1
#> - fontawesome 0.5.2
#> - fs 1.6.3
#> - glue 1.6.2
#> - highr 0.10
#> - htmltools 0.5.7
#> - jquerylib 0.1.4
#> - jsonlite 1.8.7
#> - knitr 1.45
#> - lifecycle 1.0.4
#> - magrittr 2.0.3
#> - memoise 2.0.1
#> - mime 0.12
#> - rappdirs 0.3.3
#> - rlang 1.1.2
#> - rmarkdown 2.25
#> - sass 0.4.7
#> - stringi 1.8.1
#> - stringr 1.5.1
#> - tinytex 0.49
#> - vctrs 0.6.4
#> - xfun 0.41
#> - yaml 2.3.7
#>
#> They will be copied into the project library.
#>
#> - Copying packages into the project library ... Done!
#> - Hydrated 31 packages in 0.27 seconds.
#> - The project is out-of-sync -- use `renv::status()` for details.
#> → Recording changes in lockfile
#> The following package(s) will be updated in the lockfile:
#>
#> # RSPM -----------------------------------------------------------------------
#> - R6 [* -> 2.5.1]
#> - base64enc [* -> 0.1-3]
#> - bslib [* -> 0.6.0]
#> - cachem [* -> 1.0.8]
#> - cli [* -> 3.6.1]
#> - digest [* -> 0.6.33]
#> - ellipsis [* -> 0.3.2]
#> - evaluate [* -> 0.23]
#> - fastmap [* -> 1.1.1]
#> - fontawesome [* -> 0.5.2]
#> - fs [* -> 1.6.3]
#> - glue [* -> 1.6.2]
#> - highr [* -> 0.10]
#> - htmltools [* -> 0.5.7]
#> - jquerylib [* -> 0.1.4]
#> - jsonlite [* -> 1.8.7]
#> - knitr [* -> 1.45]
#> - lifecycle [* -> 1.0.4]
#> - magrittr [* -> 2.0.3]
#> - memoise [* -> 2.0.1]
#> - mime [* -> 0.12]
#> - rappdirs [* -> 0.3.3]
#> - renv [* -> 1.0.3]
#> - rlang [* -> 1.1.2]
#> - rmarkdown [* -> 2.25]
#> - sass [* -> 0.4.7]
#> - stringi [* -> 1.8.1]
#> - stringr [* -> 1.5.1]
#> - tinytex [* -> 0.49]
#> - vctrs [* -> 0.6.4]
#> - xfun [* -> 0.41]
#> - yaml [* -> 2.3.7]
#>
#> The version of R recorded in the lockfile will be updated:
#> - R [* -> 4.3.2]
#>
#> - Lockfile written to "/tmp/RtmpyvAm1R/file18d27f04eb9e/renv/profiles/lesson-requirements/renv.lock".
#> ✔ Lesson successfully created in /tmp/RtmpyvAm1R/file18d27f04eb9e
#> → Creating Lesson in /tmp/RtmpyvAm1R/file18d27f04eb9e...
lsn
#> /tmp/RtmpyvAm1R/file18d27f04eb9e