将演绎器的列联表导出为 csv 或 xls

发布于 2024-12-21 21:57:09 字数 1662 浏览 1 评论 0原文

我正在使用 JGR 并使用 Deducer,并且我正在使用 Deducer 创建列联表和频率。我最感兴趣的是导出这些列联表并将它们保存为 .csv 或 xls 文件。

出于我的目的,我不需要卡方或类似的东西,只需要交叉表和总计。当然,越简单越好,但任何帮助将不胜感激。

这是一般代码和输出的样子(来自 Hmisc 表创建

   Cell Contents
|-------------------------|
|                   Count |
|             Row Percent |
|          Column Percent |
|-------------------------|

Total Observations in Table:  524 

             | asq[, 23] 
    asq[, 4] |        1  |        2  |        3  |        4  |        5  | Row Total | 
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
           0 |       76  |       54  |       93  |       46  |       54  |      323  | 
             |   23.529% |   16.718% |   28.793% |   14.241% |   16.718% |   61.641% | 
             |   54.286% |   56.250% |   63.265% |   63.889% |   78.261% |           | 
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
           1 |       64  |       42  |       54  |       26  |       15  |      201  | 
             |   31.841% |   20.896% |   26.866% |   12.935% |    7.463% |   38.359% | 
             |   45.714% |   43.750% |   36.735% |   36.111% |   21.739% |           | 
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
Column Total |      140  |       96  |      147  |       72  |       69  |      524  | 
             |   26.718% |   18.321% |   28.053% |   13.740% |   13.168% |           | 
-------------|-----------|-----------|-----------|-----------|-----------|-----------|

谢谢!

I am working with JGR and using Deducer, and I am creating contingency tables and frequencies using Deducer. I'm mostly interested in exporting these contingency tables and saving them as .csv or xls files.

For my purposes, I don't need the chi-sq or anything like that, just the cross tabs and totals. Of course, the easier the better, but any help would be greatly appreciated.

Here's what the general code and output looks like (coming from Hmisc Table Creation)

   Cell Contents
|-------------------------|
|                   Count |
|             Row Percent |
|          Column Percent |
|-------------------------|

Total Observations in Table:  524 

             | asq[, 23] 
    asq[, 4] |        1  |        2  |        3  |        4  |        5  | Row Total | 
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
           0 |       76  |       54  |       93  |       46  |       54  |      323  | 
             |   23.529% |   16.718% |   28.793% |   14.241% |   16.718% |   61.641% | 
             |   54.286% |   56.250% |   63.265% |   63.889% |   78.261% |           | 
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
           1 |       64  |       42  |       54  |       26  |       15  |      201  | 
             |   31.841% |   20.896% |   26.866% |   12.935% |    7.463% |   38.359% | 
             |   45.714% |   43.750% |   36.735% |   36.111% |   21.739% |           | 
-------------|-----------|-----------|-----------|-----------|-----------|-----------|
Column Total |      140  |       96  |      147  |       72  |       69  |      524  | 
             |   26.718% |   18.321% |   28.053% |   13.740% |   13.168% |           | 
-------------|-----------|-----------|-----------|-----------|-----------|-----------|

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

又怨 2024-12-28 21:57:09

在 Deducer 中没有特别好的方法来做到这一点(尽管也许应该有)。如果您使用 DeducerRichOutput,则表格格式为 html,并且可以复制/粘贴到 Excel 中。您可以使用以下命令安装它:

install.packages("DeducerRichOutput",,"http://r-forge.r-project.org",type="source")

如果您想以编程方式执行此操作,最好使用基本 R。

xt <- xtabs(~gear+cyl,data=mtcars)
write.csv(addmargins(xt),"tmp.csv")

There is not a particularly good way to do this in Deducer (though perhaps there should be). If you are using DeducerRichOutput then tables are formatted as html and can be copy/pasted into excel. You can install it with:

install.packages("DeducerRichOutput",,"http://r-forge.r-project.org",type="source")

If you want to do this programatically, you are best off using base R.

xt <- xtabs(~gear+cyl,data=mtcars)
write.csv(addmargins(xt),"tmp.csv")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文