我試圖創建一個比較年收入的陰謀,但我無法得到它的工作,不明白爲什麼。比較每年的收入
考慮我的DF:
df <- data.frame(date = seq(as.Date("2016-01-01"), as.Date("2017-10-01"), by = "month"),
rev = rnorm(22, 150, sd = 20))
df %>%
separate(date, c("Year", "Month", "Date")) %>%
filter(Month <= max(Month[Year == "2017"])) %>%
group_by(Year, Month) %>%
ggplot(aes(x = Month, y = rev, fill = Year)) +
geom_line()
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
我真的不明白爲什麼這是行不通的。我想要的是從1月到10月的兩條線。