R上的Crosstable软件包:如何仅显示百分比?

发布于 2025-01-26 10:01:31 字数 445 浏览 2 评论 0原文

我如何仅在R上显示crosstable()函数的百分比?我不希望这些数字在下面的示例中显示。

这是我的代码的一个示例:

control <- crosstable(ce_merged, c(msgctrl1_emotion, msgctrl2_emotion, msgctrl3_emotion, msgctrl4_emotion, msgctrl5_emotion), by=condition, percent_digits=0) %>%
  as_flextable(keep_id=FALSE)
control

输出的示例:

“输出的示例”

How do I only show percentages with the crosstable() function on R? I don't want the numbers to show on my example below.

Here's an example of my code:

control <- crosstable(ce_merged, c(msgctrl1_emotion, msgctrl2_emotion, msgctrl3_emotion, msgctrl4_emotion, msgctrl5_emotion), by=condition, percent_digits=0) %>%
  as_flextable(keep_id=FALSE)
control

Example of output:

EXAMPLE OF OUTPUT

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

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

发布评论

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

评论(1

淡淡的优雅 2025-02-02 10:01:31

如果没有可重现的示例,就很难回答,但是这里的关键是使用percent_pattern,只有您感兴趣的百分比(如果需要的话,以及一些装饰文本)。

control <- crosstable(ce_merged, c(msgctrl1_emotion, msgctrl2_emotion), 
                      by=condition, percent_digits=0, 
                      percent_pattern="pct={p_row}") %>%
  as_flextable(keep_id=FALSE)

您可以在文档中看到有关此信息的更多信息: httpps:https:// danchaltiel。 github.io/crosstable/reference/crosstable.html#percent-pattern

It is difficult to answer without a reproducible example, but the key here is to use percent_pattern with only the percentage you are interested in (and some decoration text if needed).

control <- crosstable(ce_merged, c(msgctrl1_emotion, msgctrl2_emotion), 
                      by=condition, percent_digits=0, 
                      percent_pattern="pct={p_row}") %>%
  as_flextable(keep_id=FALSE)

You can see more about this in the documentation: https://danchaltiel.github.io/crosstable/reference/crosstable.html#percent-pattern

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文