This commit is contained in:
Mariusz Sielski 2019-01-27 13:06:44 +01:00
parent 37cc132e32
commit ddec9adfa4

View File

@ -11,6 +11,19 @@ con <- DBI::dbConnect(
countries <- tbl(con, "dim_countries")
drugs <- tbl(con, "dim_drugs")
time <- tbl(con, "dim_time")
status <- tbl(con, "dim_claim_statuses")
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") +
scale_x_continuous(breaks = 2009:2016) +
facet_grid(. ~ status_description)
tbl(con, "FT_Refund") %>%
inner_join(countries, by = c("country_fk" = "country_sk")) %>%
@ -20,11 +33,26 @@ tbl(con, "FT_Refund") %>%
geom_point() +
xlab("Cena") +
ylab("% zniki")
tbl(con, "FT_Refund") %>%
inner_join(time, by = c("response_time_fk" = "time_sk")) %>%
filter(year == 2009) %>%
head(n = 500) %>%
select(year, month, day, price)
inner_join(drugs, by = c("drug_fk" = "drug_sk")) %>%
filter(year %in% c(2009, 2010)) %>%
mutate(sale = ifelse(reimbursement_amountPercent > 30, "on sale", "not on sale")) %>%
ggplot(aes(month, price, fill = drug_product_family_name)) +
geom_bar(stat = "identity") +
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) %>%
summarize(how_many = sum(cnt)) %>%
filter(how_many > 0) %>%
mutate(decade = floor(year / 10) * 10) %>%
ggplot(aes(year, how_many)) +
geom_area()