【发布时间】:2021-02-22 23:38:04
【问题描述】:
我有两个 r 块组成两个图表,但我想将它们保留在两个图表中,但将它们放入一个 r 块中我该怎么做
accidents %>%
filter(day_of_week != c("Sunday", "Saturday")) %>%
ggplot(mapping = aes(x = time, fill=severity)) +
geom_density(adjust = 2, alpha = 0.5) +
labs(
x = "time",
y = "Density",
title = "accidents in weekdays"
)
accidents %>%
filter(day_of_week == c("Sunday", "Saturday")) %>%
ggplot(mapping = aes(x = time, fill=severity)) +
geom_density(adjust = 2, alpha = 0.5) +
labs(
x = "time",
y = "Density",
title = "accidents in weekends"
)
【问题讨论】:
-
我认为
filter条件不正确 -
如果您将两个图的代码保存在 Markdown 中的同一块中,它将打印两个图。
标签: r ggplot2 merge chunks graphing