Learn R Programming

FactoInvestigate (version 1.9)

writeRmd: Write Rmarkdown file

Description

Writes text or dumps a variable in a Rmarkdown file, and declares the utilisation and the configuration of a chunk.

Usage

writeRmd(..., file = "", append = TRUE, sep = " ", end = "\n", dump = FALSE, 
         start = FALSE, stop = FALSE, options = NULL)

Arguments

...

some R objects or other arguments to pass to the cat function.

file

the file path where to write the description in Rmarkdown langage. If not specified, the description is written in the console.

append

a boolean, if TRUE the text is written at the end of the file. Else it is overwritten.

sep

a character chain to insert between each element written in the file (by default a blank space).

end

a character chain to add at the end of the text written in the file (by default a line break).

dump

a boolean : if TRUE, the text send to the function is interpreted as a variable name. A dump as to be written in a chunck declaration.

start

a boolean : if TRUE, the text written is preceded by a beginning chunk declaration.

stop

a boolean : if TRUE, the text written is preceded by a ending chunk declaration.

options

a character chain listing the options to declare for a chunk declaration.

Author

Simon Thuleau and Francois Husson

Details

To learn about all the possible chunck options, see https://yihui.org/knitr/options.
Anyway, to declare a R langage chunk, write at least "r" as option.

See Also

createRmd, readRmd

Examples

Run this code
if (FALSE) {
require(FactoMineR)
data(decathlon)
res.pca = PCA(decathlon, quanti.sup = c(11:12), quali.sup = c(13), graph = FALSE)
create.rmd(res.pca, file = "PCA.Rmd", document = "pdf_document")

drawn = selection(res.pca)$drawn

writeRmd(start = TRUE, options = "r, echo = FALSE, fig.align = 'center', fig.height = 3.5, 
         fig.width = 5.5", file = "PCA.Rmd", end = "")
writeRmd("drawn", file = file, dump = TRUE)
writeRmd("plot.PCA(res, select = drawn, choix = 'ind', invisible = 'quali', title = '')", 
         stop = TRUE, file = "PCA.Rmd")
           
writeRmd("**", figure.title, " - ", "Individuals factor map (PCA)", "**", file = "PCA.Rmd", 
         sep = "")
}

Run the code above in your browser using DataLab