r - 分类变量的统计摘要 - 学术论文
问题描述
我正在为 R 中的分类变量准备一个汇总统计数据,以放入学术论文中。我正在寻找这样的输出:
创建不同长度的分类变量的汇总表 但是,我找不到分类变量的函数。
这是我的小例子:
library(dplyr)
library(stargazer)
mtcars %>%
mutate(mpg_cat = ifelse(mpg > mean(mpg), 1,0)) %>%
mutate(mpg_cat= as.factor(mpg_cat)) %>%
mutate(cyl_cat= as.factor(cyl)) %>%
select(cyl_cat, mpg_cat ) %>%
function() %>% ##???
stargazer(summary=FALSE, rownames=FALSE,
#note you have to specify type
type = "html",
#note that the argument is "out" not "file"
out="temp.doc")
这是我脑海中的输出: https ://i.stack.imgur.com/CIdIa.jpg
解决方案
假设您有数据来填充这样的模板,请使用该库kableExtra
:
https://haozhu233.github.io/kableExtra/awesome_table_in_pdf.pdf。
(见第 14-20 页)
你最好学习如何处理表格,这个库也使用%>%
你已经知道的符号。
推荐阅读
- python - 如何在 Slack webClient 中更改 file_upload 格式
- java - java.lang.IllegalStateException:这个消费者已经被关闭
- react-native - 如何正确重用 useEffect 挂钩
- mysql - SELECT 在 MySQL 中连接 N:N 关系
- git - 在 git log 中仅显示历史合并分支和我未合并的分支
- python - Python,我如何在文件夹中找到以特定格式结尾的文件
- python - 多输入模型keras的K.function
- vim - vim windows 不显示带有 utf-8 的字符 $。区分vim编码问题和windows10 openssh服务器问题
- postgresql - 如果它说我没有权限这样做,我该如何在 postgresql 中使用 COPY?
- javascript - 在 ngAfterViewInit 中启动的带有 CanvasJS 图表的 Angular