【问题标题】:R ggplot2: Bar chart for the answers on the question with multiple response optionR ggplot2:带有多个响应选项的问题答案的条形图
【发布时间】:2023-01-29 01:06:53
【问题描述】:

我想为带有多个响应选项的问题的答案制作一个条形图。该代码有效,但图表显示没有标题的附加列。此列来自哪里,我该如何删除它?它与 NA 有某种关系吗?

这是代码:

Q10 <- ggplot(data = df) + 
  geom_bar(mapping = aes(x = Q10a, fill = Time),
           position = "dodge", na.rm = TRUE) +
  geom_bar(mapping = aes(x = Q10b, fill = Time),
           position = "dodge", na.rm = TRUE) +
  geom_bar(mapping = aes(x = Q10c, fill = Time),
           position = "dodge", na.rm = TRUE) +
  geom_bar(mapping = aes(x = Q10d, fill = Time),
           position = "dodge", na.rm = TRUE) +
  geom_bar(mapping = aes(x = Q10e, fill = Time),
           position = "dodge", na.rm = TRUE) +
  theme(axis.text.x = element_text(size = 10, angle = 90))
Q10

这是结果: enter image description here

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    我认为这可能与多重响应选项中的 NA 有关。也许您可以尝试在绘图之前从数据框中删除 NA。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多