2016-10-07 2 views
0

Pander를 사용하여 렌더링 된 테이블을 포함하는 Rmarkdown 문서에서 2 열 레이아웃을 사용하려고했습니다. 테이블의 열 너비를 렌더링 할 싶습니다 있지만 모든 옵션을 시도한 작동하지 않는 것. 다음은 간단한 예입니다.Rmarkdown의 Pander 테이블 너비

--- 
title: "Untitled" 
output: html_document 
--- 

```{r setup, include=FALSE} 
knitr::opts_chunk$set(echo = TRUE) 
``` 

<div class = "row"> 
<div class = "col-md-6"> 

## R Markdown 

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>. 

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: 

```{r cars, fig} 
plot(pressure) 
``` 
</div> 

<div class = "col-md-6"> 
## Including Plots 

You can also embed plots, for example: 

```{r pressure, echo=FALSE} 
library(pander) 
pander(pressure) 
``` 

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. 
</div> 
</div> 
+0

'pander'는 markdown 테이블을 생성하고'pandoc'은'rmardkdown'의 일부로 HTML (또는 필요한 다른 문서 포맷)으로 변환합니다. 테이블/열의 전체 너비로 테이블을 늘리고 싶다면 CSS보다는 (HTML을 사용할 때) 문제라고 생각합니다. 마크 다운 테이블 정의는 그다지 관련이 없습니다. – daroczig

답변

1

팬더를 사용하지 않았지만이 경우에는 kable이 더 좋을 수도 있음을 알게되었습니다. 청크 옵션을 results='asis'으로 변경하고 kable을 사용해야합니다. 테이블의 추가 서식은 table.attr 매개 변수와 부트 스트랩 테이블 클래스 (http://v4-alpha.getbootstrap.com/content/tables/)를 사용하여 쉽게 추가 할 수 있습니다.

```{r pressure, echo=FALSE, results='asis'} 
library(knitr) 
#pander(pressure, convert = "html") 
kable(pressure, format = "html", table.attr='class="table table-hover"') 
```