Description Usage Arguments Details Value Author(s) See Also Examples
Parses an R source file and returns an R markdown document that can be turned into a human readable documentation of what the source file does.
1 |
file |
a file name or connection (see |
out |
an output file name passed to |
header |
logical, if a yaml header (enclosed between tribple dashes, |
extra |
character, optional string that is placed into the code chunk openings. |
Leading double hashes ##
treated as non-code.
Leading #
followed by other than #
is code comment.
Leading #
after whitespace is code comment.
A newline is code when preceded and followed by code.
The leading double hash ##
is trimmed for comment lines.
R markdown chunk start/end stuff is added for code chunks.
The argument extra
adds chunk arguments, e.g.
extra=', eval=FALSE'
etc. See R markdown website at
https://rmarkdown.rstudio.com/
Returns a character vector invisibly, and writes a file as a side effects
unless out=NULL
in which case no file is written.
Peter Solymos <solymos@ualberta.ca>
https://rmarkdown.rstudio.com/
1 2 3 4 5 | ## Not run:
(r2rmd(system.file("r2rmd_example.R", package="mefa4"),
out=NULL, extra=", eval=FALSE"))
## End(Not run)
|
Loading required package: Matrix
Loading required package: pbapply
mefa4 0.3-4 2016-10-12
[1] "---"
[2] "title: \"r2rmd function usage example\""
[3] "author: \"Peter Solymos\""
[4] "date: \"May 13, 2015\""
[5] "output: pdf_document"
[6] "---"
[7] ""
[8] "# Rules"
[9] ""
[10] " * leading `##` is treated as *non-code*"
[11] " * leading `#` followed by other than `#` is *code comment*"
[12] " * leading `#` after whitespace is *code comment*"
[13] " * newline is *code* when preceded and followed by code"
[14] ""
[15] " The leading double hash `##` trimmed for comment lines."
[16] " R markdown chunk start/end stuff is added for code chunks."
[17] " The argument `extra` adds chunk arguments, e.g. `extra=', eval=FALSE'` etc."
[18] " The function returns vector if `out=NULL`."
[19] ""
[20] "# Trivial example"
[21] ""
[22] " Addition"
[23] "```{r CHUNK_1, eval=FALSE}\na <- 1"
[24] "b <- a + 1 # comment\n```\n"
[25] " Function"
[26] "```{r CHUNK_2, eval=FALSE}\n# another comment"
[27] "f <- function(x) x + a"
[28] "f (b)\n```\n"
[29] " That's all folks!"
[30] ""
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.