This commit is contained in:
Mariusz Sielski 2019-01-27 14:04:28 +01:00
parent 3f4c773d91
commit d6c1eb612a

View File

@ -60,17 +60,25 @@ tbl(con, "FT_Refund") %>%
facet_grid(sale ~ year) facet_grid(sale ~ year)
tbl(con, "FT_Registration") %>% registration_decades <- tbl(con, "FT_Registration") %>%
inner_join(time, by = c("submission_date_fk" = "time_sk")) %>% inner_join(time, by = c("submission_date_fk" = "time_sk")) %>%
inner_join(status, by = c("claim_status_fk" = "claim_status_sk")) %>% inner_join(status, by = c("claim_status_fk" = "claim_status_sk")) %>%
mutate(decade = floor(year / 10) * 10, got_answer = status_code_bk != "W") %>% mutate(decade = floor(year / 10) * 10, got_answer = status_code_bk != "W") %>%
filter(decade < 2020, decade >= 1980)
with_grouping_by_answer <- registration_decades %>%
group_by(decade) %>%
summarize(how_many = sum(cnt))
registration_decades %>%
group_by(decade, got_answer) %>% group_by(decade, got_answer) %>%
summarize(how_many = sum(cnt)) %>% summarize(how_many = sum(cnt)) %>%
filter(how_many > 0, decade < 2020, decade >= 1980) %>% filter(how_many > 0) %>%
ggplot(aes(decade, how_many, fill = got_answer)) + ggplot(aes(decade, how_many, fill = got_answer)) +
geom_bar(stat = "identity") + geom_bar(stat = "identity") +
geom_label(aes(label = how_many)) + geom_label(aes(label = how_many)) +
geom_text(stat = "count", y = 5000, aes(label = ..count..)) geom_label(data = with_grouping_by_answer, aes(y = how_many, label = how_many, fill = NULL))