Description Usage Arguments Value Examples
This function can be used to insert any line or lines of code
into an R Markdown file. The chunk will be inserted into the file called
filename.Rmd
, which must exist in the current working directory. Chaining
with %>%
is possible, by returning filename
from the function.
1 | insertChunk(filename, object, chunktitle = NULL)
|
filename |
Character giving the name of the R Markdown file that the
chunk should be inserted into, minus the |
object |
Can be any quoted or unquoted line of R code, i.e. a call to a function to insert a
single line. To insert more than one line, pass as a vector of type |
chunktitle |
Single or vector of character/s giving an optional markdown header that will be
included before the code chunk e.g. of the form |
Returns filename
so that functions can be chained to write
to the same file consecutively
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
## Insert single chunk, chained from createFile() function
createFile("Mtcars") %>% insertYAML(title = "Test", author = "J. Bloggs") %>%
insertLibraries() %>%
insertChunk(summary(mtcars), title = "#Summary")
insertChunk("summary(mtcars)", title = "#Summary") would also work
## Insert multiple chunks to existing file, with headers
insertChunk("Mtcars.Rmd",
expression(
plot(mtcars$cyl, mtcars$hp),
multivariateCorrelation(mtcars)),
title= c("##Scatter Plot",
"##Correlations"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.