Programmatically insert text, headers and lists with R markdown -


When you want to add text using a code, there are a few simple ways to do this when using R markdown

This is also very simple for tables using the kable command.

However, imagine that you want to programmatically place headers or lists in your report (in I_list_a)

  `` {r, result = Asis'} header = list ("we", "are", "your", "friend") {#add i as header} ``  

and you want it to be The RMD file will be like the following:

  # we # your friends  

will have to create an auto header instead of another example list:

  `` `{r, result = 'asis'} list_a = before this list (" The same as writing {`print_print i} in rmd list}` ``  

for "we", "are", "your", "friend") (in i_list_a) The result should be:

  * we are * your * friends  

This is not just a formatting problem in the form of tables according to these headers RMD files are dynamically created in the context of.

You need to build your desired markdown in R and logic in your chunk options Use together with results = 'asis' . Therefore, some of the following will do what you want:

  `` {r, result = 'asis'} heading & lt; - ("" "(" # "," "," "" (for " P> Here will create output for loop  
  # we are # your friends  

which is used as input directly in the .rmd document


Comments