-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update summary stats on Here probe fleet size (#139)
* estimate size of the HERE fleet * add comment * obscure DB host * update docs * add link * comment/document
- Loading branch information
1 parent
65c6a59
commit 2a82edd
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
library('tidyverse') | ||
library('dbplyr') | ||
|
||
con <- DBI::dbConnect( | ||
RPostgres::Postgres(), | ||
host = 'insert DB host here', | ||
user = 'nwessel', | ||
dbname = 'bigdata', | ||
password = rstudioapi::askForPassword("Database password") | ||
) | ||
|
||
# The idea here is to convert average speeds and lengths of links into *time* | ||
# The total amount of time spent traveling by vehicles in a given unit of time | ||
# just is the average total number of vehicles reporting their locations to Here | ||
tbl( con, in_schema('here','ta_path') ) %>% | ||
filter( dt == '2024-07-18' ) %>% | ||
mutate( hours = sample_size * ((length / 1000) / mean) ) %>% | ||
group_by( tod ) %>% | ||
summarize( | ||
# x 12 because otherwise we'd have the number of hours in a five-minute bin | ||
probe_count = 12 * sum(hours) | ||
) %>% | ||
ggplot( aes(x = tod, y = probe_count) ) + | ||
geom_line() |