【发布时间】:2018-08-29 23:09:50
【问题描述】:
我正在尝试在 ggplot 中绘制 Current_Prices 和 Test_Prices,例如 fill,但在 dplyr 中运行汇总后,我无法弄清楚合并这两列的函数。
carrier%>%
group_by(!!category) %>%
summarise(Current_Prices = mean(original_percent_higher[original_percent_higher>0], na.rm = TRUE),
Test_Prices = mean(Percent_Higher[Percent_Higher>0], na.rm = TRUE)) %>%
ggplot(aes_string(input$Category, "Current_Prices")) +
geom_bar(stat = "identity", position = "dodge", na.rm = TRUE) +
geom_text(aes(label = scales::percent(Current_Prices)), size = 3.2, vjust = -0.5,
position = position_dodge(width = 1), na.rm = TRUE)
我想在 summarise 和 ggplot 之间创建类似于:
Class Version Mean
a current 1
a test 2
b current 3
b test 4
然后我可以运行 ggplot,其中 Class 作为 x,Mean 作为 y,Version 作为填充。
总结后我现在拥有的是这样的:
Class Current Test
a 1 2
b 3 4
c 5 6
【问题讨论】:
-
请展示一个小的可重复的初始数据示例