如何在降价中调整 R 输出 table 的大小?

How do I resize an R output table in markddown?

我一直在找时间在降价时调整 table 的大小,以免它损坏。我考虑过减少源代码或强制它不要中断,但我该怎么做呢?我只找到使用 kable 或 kableextra 的解决方案,但我想要默认样式。我把数据留在了 url.

data

我们可以更改 options 中的 width。检查当前 width 并进行这些更改

> head(cbind(iris, iris, iris))
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species Sepal.Length Sepal.Width Petal.Length Petal.Width Species Sepal.Length Sepal.Width Petal.Length
1          5.1         3.5          1.4         0.2  setosa          5.1         3.5          1.4         0.2  setosa          5.1         3.5          1.4
2          4.9         3.0          1.4         0.2  setosa          4.9         3.0          1.4         0.2  setosa          4.9         3.0          1.4
3          4.7         3.2          1.3         0.2  setosa          4.7         3.2          1.3         0.2  setosa          4.7         3.2          1.3
4          4.6         3.1          1.5         0.2  setosa          4.6         3.1          1.5         0.2  setosa          4.6         3.1          1.5
5          5.0         3.6          1.4         0.2  setosa          5.0         3.6          1.4         0.2  setosa          5.0         3.6          1.4
6          5.4         3.9          1.7         0.4  setosa          5.4         3.9          1.7         0.4  setosa          5.4         3.9          1.7
  Petal.Width Species
1         0.2  setosa
2         0.2  setosa
3         0.2  setosa
4         0.2  setosa
5         0.2  setosa
6         0.4  setosa
> op <- options()
> options()$width # check the current width
[1] 167
> options(width = 300) # change the width and now do the print again
> head(cbind(iris, iris, iris))
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species Sepal.Length Sepal.Width Petal.Length Petal.Width Species Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa          5.1         3.5          1.4         0.2  setosa          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa          4.9         3.0          1.4         0.2  setosa          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa          4.7         3.2          1.3         0.2  setosa          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa          4.6         3.1          1.5         0.2  setosa          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa          5.0         3.6          1.4         0.2  setosa          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa          5.4         3.9          1.7         0.4  setosa          5.4         3.9          1.7         0.4  setosa

完成后,再次重置 options

> options(op)
> options()$width
[1] 167