并排显示时控制 table 的宽度

Control table's width when displayed side by side

有没有办法像下面的示例那样并排显示时分别控制每个 table 的宽度?

```{r sample, echo=FALSE}
library(knitr)
library(kableExtra)
t1 <- head(mtcars)[1:3]
t2 <- head(mtcars)[4:6]
```

```{r, echo = FALSE}
kable(t1) %>%
  kable_styling(full_width = FALSE, position = "float_left")
kable(t2) %>%
  kable_styling(full_width = FALSE, position = "left")
```

例如,我希望下面第一个 table 的宽度是第二个 table 的两倍。

我试过 kable(format = 'html', table.attr = "style='width:80%;'") 但它不起作用,我也不知道为什么。宽度完全没有变化。

I tried kable(format = 'html', table.attr = "style='width:80%;'") but it doens't work and I don't know why. The width doesn't change at all.

你非常接近,只需将 full_width 指定为 TRUE:

```{r, echo = FALSE}
kable(t1, format = "html", table.attr = "style = 'width: 69%;'") %>%
  kable_styling(full_width = TRUE, position = "float_left")
kable(t2) %>%
  kable_styling(full_width = FALSE, position = "left")
```

输出: