簡體   English   中英

R上的交叉表包:如何只顯示百分比?

[英]Crosstable package on R: How to only show percentages?

如何僅使用 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

輸出示例:

輸出示例

如果沒有可重復的示例,很難回答,但這里的關鍵是使用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)

您可以在文檔中看到更多相關信息: https ://danchaltiel.github.io/crosstable/reference/crosstable.html#percent-pattern

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM