View source: R/format_tutorial.R
format_tutorial | R Documentation |
This function processes an R Markdown tutorial file to standardize code chunk labels based on section names and exercise numbers. It also renumbers exercises sequentially within each section.
format_tutorial(file_path)
file_path |
Character string. Path to the R Markdown file to process. |
The function applies the following formatting rules:
Exercises are renumbered sequentially within each section
Code chunks are relabeled according to the pattern: section-name-exercise-number
Chunks with eval = FALSE
receive a -hint-N
suffix
Chunks with include = FALSE
receive a -test
suffix
Chunks with label "setup" are not modified
Chunks with the "file" option are not modified
Unlabeled chunks without key options are not modified
All formatted chunks preserve their original options
Content between quadruple backticks (
) is preserved untouched
Character string containing the formatted R Markdown content.
## Not run:
# Format a tutorial file
new_content <- format_tutorial("path/to/tutorial.Rmd")
# Write the formatted content to a file
writeLines(new_content, "path/to/formatted_tutorial.Rmd")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.