Programmatically insert text, headers and lists with R markdown

后端 未结 4 2156
时光说笑
时光说笑 2020-12-05 07:23

When using R markdown if one wants to add text using code there are some simple ways to do it.

This is also true for tables, using the kable command is

4条回答
  •  一整个雨季
    2020-12-05 07:43

    Use the pander package, which transform R objects into Pandoc's markdown:

    > headers=list("We","are","your","friends")
    > list_a=list("We","are","your","friends")
    > library(pander)
    > pandoc.header(headers)
    
    # We
    
    # are
    
    # your
    
    # friends
    > pander(list_a)
    
    
      * We
      * are
      * your
      * friends
    
    
    

    The first example used a helper function to create the headers, while the second demo simply called the generic S3 method, that can robustly transform a variety of R objects into markdown.

提交回复
热议问题