使用循环应用 epidisplay 中的 tab1 函数
我有一个包含 172 个变量的数据集,我正在尝试为所有变量生成频率表(它们都是分类/字符变量)。我正在使用 epiDisplay 包中的 tab1 函数。我知道如何对单个变量执行此操作,就像我在下面的代码中所做的那样,但是有没有办法一次完成所有操作?我将如何使用循环或 lapply 来做到这一点?
library(epiDisplay)
tab1(data$Race1, sort.group = "decreasing", cum.percent = TRUE)
谢谢!
I have a dataset with 172 variables and I'm trying to generate frequency tables for all of the variables(they're all categorical/character variables). I'm using the tab1 function from the epiDisplay package. I know how to do it for individual variables like I've done in my code below, but is there a way to do it all at once? How would I do this using a loop or lapply?
library(epiDisplay)
tab1(data$Race1, sort.group = "decreasing", cum.percent = TRUE)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能有几种方法可以做到这一点。这可能想尝试这样的事情:
如果你不需要图表:
There might be several ways to do it. This may want to try something like this:
If you do not need graph: