Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将大频率表适配到R降价iSlide中?_R_R Markdown_Ioslides - Fatal编程技术网

如何将大频率表适配到R降价iSlide中?

如何将大频率表适配到R降价iSlide中?,r,r-markdown,ioslides,R,R Markdown,Ioslides,我正试着在我的幻灯片中加入大量的频率表。有很多价值观,即使是罕见的价值观也很值得展示 我有不同的选择,但没有一个能给我一个满意的解决方案。以下是迄今为止的Rmd: --- title: "Untitled" author: "author" date: "date" output: ioslides_presentation --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) df <- as.data.

我正试着在我的幻灯片中加入大量的频率表。有很多价值观,即使是罕见的价值观也很值得展示

我有不同的选择,但没有一个能给我一个满意的解决方案。以下是迄今为止的
Rmd

---
title: "Untitled"
author: "author"
date: "date"
output: ioslides_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
df <- as.data.frame(table(rownames((USArrests))))
```

## table 1

```{r t1, echo = TRUE}
table(rownames((USArrests)))
```

## table 2

```{r t2}
library(knitr)
library(kableExtra)
kable(df, "html") %>%
  kable_styling(bootstrap_options = "striped", font_size = 10)
```
---
标题:“无标题”
作者:“作者”
日期:“日期”
输出:ioslides\u演示文稿
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=FALSE)
df%
kable_样式(bootstrap_options=“striped”,font_size=10)
```
表1不适合:

表2可以压缩,但字体很小,并且在侧面浪费了很多空间

我还研究了
pander
xtable
stargazer
,但也没有从中找到解决方案


还有其他选择吗?

您可以将表格分散到多个列中以适应空间。在下面的示例中,我将框架拆分为3对长度不均匀的列

---
output: ioslides_presentation
---

```{r setup, include=FALSE}
library(dplyr)
library(magrittr)
library(knitr)
library(kableExtra)
```

## table 1

```{r, echo=TRUE, eval=FALSE}
USArrests %>% rownames %>% table
```

```{r, echo=FALSE}
df <- USArrests %>%
  rownames %>%
  table %>%
  as_tibble

df %$%
  tibble(
    name1 = `.`[1:17],
    n1 = n[1:17],
    name2 = `.`[18:34],
    n2 = n[18:34],
    name3 = c(`.`[35:50], ""),
    n3 = c(n[35:50], "")
  ) %>%
  kable("html", align = c("l", "c"), col.names = rep(c("Name", "Frequency"), 3)) %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), font_size = 18)
```
---
输出:ioslides\u演示文稿
---
```{r设置,include=FALSE}
图书馆(dplyr)
图书馆(magrittr)
图书馆(knitr)
图书馆(kableExtra)
```
##表1
```{r,echo=TRUE,eval=FALSE}
USARests%%>%rownames%%>%table
```
```{r,echo=FALSE}
df%
行名称%>%
表%>%
不可抵抗
df%$%
蒂布尔(
名称1=`.`[1:17],
n1=n[1:17],
名称2=`.`[18:34],
n2=n[18:34],
名称3=c(`.`[35:50],“”),
n3=c(n[35:50],“”)
) %>%
kable(“html”,align=c(“l”,“c”),col.names=rep(c(“名称”,“频率”),3))%>%
kable_样式(引导选项=c(“条纹”、“浓缩”),字体大小=18)
```

N.B.我接受将转换步骤转换为多列本可以更优雅地完成,并提供更具程序性的解决方案,但是,我将把这留给其他人来完善


谢谢@Kevin-完成了任务。