diff --git a/raportowanie.r b/raportowanie.r index 6e17a92..7a36e46 100644 --- a/raportowanie.r +++ b/raportowanie.r @@ -13,6 +13,7 @@ drugs <- tbl(con, "dim_drugs") time <- tbl(con, "dim_time") status <- tbl(con, "dim_claim_statuses") +# Zaakceptowane i odrzuconce refundacje w latach tbl(con, "FT_Refund") %>% inner_join(time, by = c("response_time_fk" = "time_sk")) %>% inner_join(status, by = c("claim_status_fk" = "claim_status_sk")) %>% @@ -25,6 +26,20 @@ tbl(con, "FT_Refund") %>% scale_x_continuous(breaks = 2009:2016) + facet_grid(. ~ status_description) +tbl(con, "FT_Refund") %>% + inner_join(time, by = c("response_time_fk" = "time_sk")) %>% + inner_join(status, by = c("claim_status_fk" = "claim_status_sk")) %>% + filter(year >= 2008 && year <= 2016) %>% + group_by(year, status_description) %>% + summarize(how_many = sum(cnt)) %>% + ungroup() %>% + ggplot(aes(year, how_many, fill = status_description)) + + geom_bar(stat = "identity", position = "dodge") + + geom_text(aes(label = how_many)) + + scale_x_continuous(breaks = 2009:2016) + + ylab("count") + + tbl(con, "FT_Refund") %>% inner_join(countries, by = c("country_fk" = "country_sk")) %>% inner_join(drugs, by = c("drug_fk" = "drug_sk")) %>% @@ -44,14 +59,18 @@ tbl(con, "FT_Refund") %>% scale_x_continuous("month", breaks = 1:12) + facet_grid(sale ~ year) + tbl(con, "FT_Registration") %>% - inner_join(time, by = c("response_time_fk" = "time_sk")) %>% - group_by(year) %>% + inner_join(time, by = c("submission_date_fk" = "time_sk")) %>% + inner_join(status, by = c("claim_status_fk" = "claim_status_sk")) %>% + mutate(decade = floor(year / 10) * 10, got_answer = status_code_bk != "W") %>% + group_by(decade, got_answer) %>% summarize(how_many = sum(cnt)) %>% - filter(how_many > 0) %>% - mutate(decade = floor(year / 10) * 10) %>% - ggplot(aes(year, how_many)) + - geom_area() + filter(how_many > 0, decade < 2020, decade >= 1980) %>% + ggplot(aes(decade, how_many, fill = got_answer)) + + geom_bar(stat = "identity") + + geom_label(aes(label=how_many)) + + geom_text(stat = "count", y = 5000, aes(label = ..count..))