Created
July 29, 2022 04:10
-
-
Save idshklein/e192df7dac6aff64dfb00cef4c9d9060 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pacman::p_load(tidyverse,jsonlite,lubridate) | |
rishui <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=8fd3aa6c-a64f-4c91-818e-fd35017cd19b&limit=300000") | |
rishui1 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=8fd3aa6c-a64f-4c91-818e-fd35017cd19b&offset=300000&limit=300000") | |
rishui2 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=8fd3aa6c-a64f-4c91-818e-fd35017cd19b&offset=600000&limit=300000") | |
rishui3 <- read_json("https://data.gov.il/api/3/action/datastore_search?resource_id=8fd3aa6c-a64f-4c91-818e-fd35017cd19b&offset=900000&limit=300000") | |
rishhi_all <- list(rishui,rishui1,rishui2,rishui3) | |
tbl <- rishhi_all %>% | |
map_df(~.x$result$records %>% map_df(~.x)) | |
tbl %>% glimpse() | |
tbl %>% | |
mutate(rishui_date = ymd_hms(rishui_date,tz = "Israel"), | |
date= as_date(rishui_date)) %>% | |
group_by(date) %>% | |
arrange(date,-trips_count) %>% | |
mutate(pect = trips_count/sum(trips_count), | |
cs = cumsum(pect), | |
n=n(), | |
cs1 = row_number()/n, | |
weekend = wday(date) > 5, | |
day = wday(date,label = T) %>% as.character()) %>% | |
ggplot(aes(x=cs1*100,y= cs*100,group = date,color = day)) + | |
geom_line() + | |
labs(x = "אחוז מהקווים", y = "אחוז מהנסיעות") + | |
facet_wrap(~weekend) + | |
geom_hline(yintercept = c(50,80,90,95,99)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment