2014-09-18 1 views
4

tabular() {tables}을 사용하여 R sweave 문서에서 만든 복잡한 테이블에 \hline을 추가하고 싶습니다.R의 표 {table} 객체에 추가 수평선을 추가하려면 어떻게해야합니까?

아이리스 데이터를 예로 사용 : 아이리스 세트osa 아래에 수평선을 추가하고 행 이름이 아닌 열만 추가하고자합니다. 현재,이있어 :

Example of a table with multi-coloum header

코드 테이블을 생성합니다 :

\begin{table} 
\begin{center} 
<<iristable, eval=TRUE, echo=FALSE, results='asis', message=FALSE>>= 
library(Hmisc) ; library(tables) 


tab.obj <- tabular(Species ~ (Heading("Mean")* 
            (Heading("")*mean*Sepal.Width + 
            Heading("")*mean*Sepal.Length)) + 
           (Heading("Median")* 
            (Heading("")*median*Sepal.Width + 
            Heading("")*median*Sepal.Length)), 
        data=iris) 

    nicetable<- booktabs() ## needs LaTex package \usepackage{booktabs} 
    table_options(nicetable) 
    table_options(titlerule="\\cmidrule(lr)") 

latex(tab.obj) 
@ 
\caption{This table is just an example.} 
\end{center} 
\label{tab:example_table} 
\end{table} 

나는 그것이 가능해야 생각,하지만 난 꽤 방법을 찾을 수 없습니다.

+0

* 포기 * : 내가 거기에 복잡하고 중첩 된 테이블을 작성하는 문제에 달려 있기 때문에 나는 다시 xtable''에 가고 싶지 않아. –

답변

0

titlerules <- sprintf("%s%s{%d-%d}", titlerules, 
         opts$titlerule, firstcol, firstcol + 
          ncols - 1) 

아닌 midrule에 대한, titlerule에 대한 클라인 인수를 계산하는 방법이 기능 tables:::latex.tabular를 찾고. 그래서 당신은 여기에 ... 수동으로해야 할

table_options 사용 (midrule = \ "의 cmidrule (LR)을 {2-3} \ cmidrule (LR) {4-5}")

\begin{table} 
\begin{center} 
<<iristable, eval=TRUE, echo=FALSE, results='asis', message=FALSE>>= 
library(Hmisc) ; library(tables) 
tab.obj <- tabular(Species ~ (Heading("Mean")* 
            (Heading("")*mean*Sepal.Width + 
            Heading("")*mean*Sepal.Length)) + 
           (Heading("Median")* 
            (Heading("")*median*Sepal.Width + 
            Heading("")*median*Sepal.Length)), 
        data=iris) 

    nicetable<- booktabs() ## needs LaTex package \usepackage{booktabs} 
    table_options(nicetable) 
    table_options(titlerule="\\cmidrule(lr)") 
    table_options(midrule="\\cmidrule(lr){2-3}\\cmidrule(lr){4-5}") 
latex(tab.obj) 
@ 
\caption{This table is just an example.} 
\end{center} 
\label{tab:example_table} 
\end{table} 

midrule_cline

관련 문제