| Title: | Notebooks Using 'Targets' and 'Bookdown' |
|---|---|
| Description: | 'Targets' is an R package for dependency and build management in data analysis projects. This package provides a set of targets and project infrastructure to create 'bookdown'-based notebooks using 'targets'. |
| Authors: | Tristan Mahr [aut, cre] (ORCID: <https://orcid.org/0000-0002-8890-5116>) |
| Maintainer: | Tristan Mahr <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.0.9004 |
| Built: | 2026-05-25 10:10:49 UTC |
| Source: | https://github.com/tjmahr/notestar |
Open the notebook in a browser or in the RStudio viewer
notebook_browse(file = NULL) notebook_view(file = NULL)notebook_browse(file = NULL) notebook_view(file = NULL)
file |
full path to the notebook file. Defaults to |
This function is called for its side effects so it return NULL
invisibly.
Creates a file with pattern [notebook_dir]/[date][-slug].Rmd.
notebook_create_page(slug = NULL, date = NULL, open = TRUE)notebook_create_page(slug = NULL, date = NULL, open = TRUE)
slug |
Optional "slug" (label) for the post. Defaults to |
date |
Optional data to use. This date should have the format
|
open |
Whether to open the new file for editing. Defaults to
|
Invisible returns the relative path to the created file.
These options are used in the knitr-helpers.R file.
notebook_set_opts_knit() notebook_set_opts_chunk() notebook_set_markdown_hooks()notebook_set_opts_knit() notebook_set_opts_chunk() notebook_set_markdown_hooks()
a list containing the default options used
This function is a wrapper over yaml::write_yaml() that works with file
targets.
notebook_write_yaml(x, file, ...)notebook_write_yaml(x, file, ...)
x, file, ...
|
arguments passed to |
the yaml file is written and the value of file is returned
Assemble knitted notebook md files into a single-page bookdown document
tar_notebook( subdir_output = "docs", extra_deps = list(), use_downlit = FALSE, markdown_document2_args = list() )tar_notebook( subdir_output = "docs", extra_deps = list(), use_downlit = FALSE, markdown_document2_args = list() )
subdir_output |
Subdirectory of |
extra_deps |
A list of extra dependencies. These should be the names of
targets defined elsewhere in the dependencies graph. Defaults to |
use_downlit |
whether to post-process the notebook with the downlit
syntax highlighter. Default is |
markdown_document2_args |
arguments to pass onto
|
The list of targets produced includes:
notebook_output_yaml, a file target for _output.yml (used by
bookdown to set output format options).
notebook_bookdown_yaml, a file target for _bookdown.yml (used by
bookdown to collate pages).
notebook, a file target for the final assembled html file used by
bookdown.
The only output format supported is an html file produced by
cleanrmd::html_document_clean().
A list of targets.
This function creates the index.Rmd file for the notebook and sets YAML
metadata in the file. It also detects CSL and bibliography file dependencies.
tar_notebook_index_rmd( title = "Notebook title", author = "Author name", bibliography = ymlthis::yml_blank(), csl = ymlthis::yml_blank(), index_rmd_body_lines = "", ..., .list = rlang::list2(...) )tar_notebook_index_rmd( title = "Notebook title", author = "Author name", bibliography = ymlthis::yml_blank(), csl = ymlthis::yml_blank(), index_rmd_body_lines = "", ..., .list = rlang::list2(...) )
title |
Title to use for the notebook. Defaults to |
author |
Author name for the notebook. Defaults to |
bibliography |
Name of a |
csl |
Name of a |
index_rmd_body_lines |
optional character vector to use for body text in
|
... |
Additional key-value pairs for setting fields in the yml metadata.
For example, |
.list |
Alternatively, these YAML fields may be set using a list. Any
key-value pairs in this list will override options set by arguments. For
example, an |
a list of targets:
notebook_bibliography_user, notebook_csl_user: file targets for
the bibliography and csl files in the dir_notebook user folder.
notebook_bibliography_asset, notebook_csl_asset: file targets for
the bibliography and csl files in the dir_md assets folder. These
command to build these targets to copy them.
notebook_index_rmd: file target for the index.Rmd file.
If any of these file targets is not used, an empty target list() is passed
along.
Create targets to knit notebook Rmd files
tar_notebook_pages()tar_notebook_pages()
The list of targets produced includes:
notebook_helper_user, a file for the user's helper R script.
notebook_helper, a mirrored copy of the notebook_helper_user
one file target for each input Rmd file. Any targets used
with tar_read() or tar_load() inside these files are detected
and checked for changes.
one file target for each output md file.
notebook_rmds, a combined target for the input .Rmd files.
notebook_mds, a combined target for the output .md files.
A list of targets.
Create a brand new notebook with default settings
use_notestar( dir_project = ".", dir_notebook = "notebook", dir_md = "notebook/book", notebook_helper = "knitr-helpers.R", cleanrmd_theme = "water", notebook_filename = "notebook", open = interactive() ) use_notestar_makefile(dir_project = ".") use_notestar_references(dir_project = ".")use_notestar( dir_project = ".", dir_notebook = "notebook", dir_md = "notebook/book", notebook_helper = "knitr-helpers.R", cleanrmd_theme = "water", notebook_filename = "notebook", open = interactive() ) use_notestar_makefile(dir_project = ".") use_notestar_references(dir_project = ".")
dir_project |
file-path to the base/root folder of the project. Defaults to
|
dir_notebook |
Name of the directory containing the Rmd files. It should
be a relative path from the project root. Defaults to |
dir_md |
Name of the directory to contain md files (knitted Rmd files).
It should be a relative path from the project root. Defaults to
|
notebook_helper |
Filename for an R script to run before knitting each
Rmd file and rendering the notebook with bookdown. The file must be in
|
cleanrmd_theme |
Theme to use for |
notebook_filename |
Name to use for the final html file. Defaults to
|
open |
whether to open |
use_notestar_makefile() creates a Makefile that will build or clean a
targets-based workflow.
use_notestar_references() adds the files "refs.bib" and "apa.csl" to
dir_notebook.