2 Column Report in R Markdown - Render HTML aside Data Frame

前端 未结 1 599
夕颜
夕颜 2020-12-09 21:30

I am looking to render a 2 column report as a stand-alone HTML file using R and Markdown only. I am very new to markdown within R, so I need some help with the layout.

相关标签:
1条回答
  • 2020-12-09 21:52

    Although this is not a perfect solution, it is a place to get started: Yihui recently added HTML templates to knitr, and docco is a example two-column page: http://cran.r-project.org/web/packages/knitr/vignettes/docco-classic.html .

    You can see the template file used for that output here: https://github.com/yihui/knitr/blob/master/inst/misc/docco-template.html.

    Alternatively, you can try placing inline HTML right in your R Markdown chunks, but this is terribly hacky and you might feel like a bad person for doing it. We use results='asis' so that the cated HTML is rendered properly, and out.extra='' to ensure that the HTML used to generate the figures is generated right away, rather than the Markdown language for image inclusion.

    ```{r two-column, results='asis', echo=FALSE, out.extra=''}
    library(knitr)
    cat("<table class='container'><tr>")
    cat("<td>")
    plot( rnorm(10) )
    cat("</td>")
    cat("<td>")
    kable( rnorm(10), format="html" )
    cat("</td>")
    cat("</tr></table>")
    ```
    

    Calling knit on that should produce a 2 column layout for that particular chunk (although without any nice styling for the table; you might add that in yourself with some CSS)

    0 讨论(0)
提交回复
热议问题