【发布时间】:2020-04-18 18:53:59
【问题描述】:
我想在条形图中绘制两列:“Property_type”和“Price”。 使用下面的代码,我将为每种房产类型绘制“总价”而不是“中位价”。 你能帮我修复代码吗?
theme_set(theme_bw())
# Draw plot
ggplot(data, aes(x=Property_type, y=Price)) +
geom_bar(stat="identity", width=.5, fill="tomato3") +
labs(title="Ordered Bar Chart",
subtitle="Average Price by each Property Type",
caption="Image: 5") +
theme(axis.text.x = element_text(angle=65, vjust=0.6))
【问题讨论】:
-
在绘图前简单聚合:
ggplot(aggregate(Price ~ Property_type, data, FUN=median), ...
标签: r ggplot2 data-visualization median