facetowanie

This commit is contained in:
Mariusz Sielski 2019-01-27 12:34:59 +01:00
parent 98c8030072
commit 37cc132e32
2 changed files with 30 additions and 0 deletions

Binary file not shown.

30
raportowanie.r Normal file
View File

@ -0,0 +1,30 @@
require(odbc)
require(dbplyr)
require(dplyr)
require(tidyr)
require(ggplot2)
con <- DBI::dbConnect(
odbc::odbc(),
.connection_string = 'driver={SQL Server};server=mssql-2016.labs.wmi.amu.edu.pl;database=bigdata_s26450;trusted_connection=true')
countries <- tbl(con, "dim_countries")
drugs <- tbl(con, "dim_drugs")
time <- tbl(con, "dim_time")
tbl(con, "FT_Refund") %>%
inner_join(countries, by = c("country_fk" = "country_sk")) %>%
inner_join(drugs, by = c("drug_fk" = "drug_sk")) %>%
head(n = 500) %>%
ggplot(aes(price, reimbursement_amountPercent, color = country_name)) +
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)