使用Hmisc LaTeX功能编织时,标题不出现在LaTeX表中

时间:2017-06-13 16:09:50

标签: r latex knitr hmisc

我正在尝试使用表和Hmisc包创建一个LaTeX表,但是我无法显示标题。

这是一个可重复的例子:

    ```{r, results = "asis"}

# data:
dow <- sample(1:7, 100, replace=TRUE)
purp <- sample(1:4, 100, replace=TRUE)
dow <- factor(dow, 1:7, c("Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun"))
purp <- factor(purp, 1:4, c("Business", "Commute", "Vacation", "Other"))

dataframe <-  data.frame( dow, purp)

# The packages
library(tables)
library(Hmisc)

# The table
#tabular(  (Weekday=dow) ~  (Purpose=purp)*(Percent("row")+ 1)    ,data=dataframe        )

# The latex table
tab <- latex(  tabular(  (Weekday=dow) ~  (Purpose=purp)*(Percent("col")+ 1)    ,data=dataframe        ), caption = "This is a Caption")
print(tab)
```

针织表不包含标题。我是LaTeX的新手,我对LaTeX的唯一体验是通过 R 和Rstudio。任何建议都将不胜感激。

Table produced when knitted

1 个答案:

答案 0 :(得分:0)

当你跑

tab <- latex(tabular(  (Weekday=dow) ~  (Purpose=purp)*(Percent("col")+ 1), data=dataframe), caption = "This is a Caption")

您正在使用默认的S3方法,在本例中为latex.tabular

## S3 method for class 'tabular'
latex(object, file = "", options = NULL, append = FALSE, ...)

latex.tabular不带标题参数