I am looking to lay over multiple years off data, based off of weeks. I am looking for the most recent year (2020) to be a bar chat, and the prior years (2019 & 2018) to be line plots.
My current code produces the visual below
data %>%
ggplot(aes(week, result, fill = year)) +
geom_col()
If I wanted to make all the years a bar chart, I know I could use "dodge" in geom_col. However, I am trying to split out the data into different geoms
When I use the subset function (code below), something strange happens with my chart and I can't figure out what is going on
data %>%
ggplot(aes(week, result, fill = year)) +
geom_col(data = subset(data, year == 2020)) +
geom_line(data = subset(data, year != 2020))
Below is a sample of the data that I am using. Any ideas on what I'm doing wrong?
structure(list(year = c("2018", "2018", "2019", "2019", "2020",
"2020"), week = c(1L, 2L, 1L, 2L, 1L, 2L), result = c(6.88475831020016,
7.62267452779933, 3.67553313593328, 6.18354398162893, 2.38101968527051,
5.9596355812872)), .Names = c("year", "week", "result"), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))