Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

R package to provide API to Melbourne pedestrian data

License

NotificationsYou must be signed in to change notification settings

earowang/rwalkr

Repository files navigation

Travis-CI Build StatusCRAN_Status_BadgeDownloads

rwalkr

The goal ofrwalkr is to provide APIs to the pedestrian andmicroclimate data from the City of Melbourne in tidy data form.

Installation

You could install the stable version from CRAN:

install.packages("rwalkr")

You could install the development version from Github using:

# install.packages("devtools")devtools::install_github("earowang/rwalkr")

Usage

APIs

There are two APIs available to access hourly Melbourne pedestrian data:compedapi andSocrata. The former drives themelb_walk() function,where counts are uploaded on a daily basis; the latter powers themelb_walk_fast() function, where counts are uploaded on a monthlybasis. Given the function names, the functionmelb_walk_fast() pullsthe data at a much faster speed thanmelb_walk().

The functionmelb_walk() specifies the starting and ending dates to bepulled, whereasmelb_walk_fast() requires years to define the timeframe. If a selection of sensors are of interest,melb_walk_fast()provides the flexibility for sensor choices.

library(rwalkr)start_date<- as.Date("2017-07-01")ped_walk<- melb_walk(from=start_date,to=start_date+6L)ped_walk#> # A tibble: 10,584 x 5#>   Sensor                     Date_Time           Date        Time Count#>   <chr>                      <dttm>              <date>     <int> <int>#> 1 Bourke Street Mall (North) 2017-07-01 00:00:00 2017-07-01     0   280#> 2 Bourke Street Mall (South) 2017-07-01 00:00:00 2017-07-01     0   177#> 3 Melbourne Central          2017-07-01 00:00:00 2017-07-01     0   826#> 4 Town Hall (West)           2017-07-01 00:00:00 2017-07-01     0   682#> 5 Princes Bridge             2017-07-01 00:00:00 2017-07-01     0     0#> # … with 10,579 more rowsped_run<- melb_walk_fast(year=2016:2017,sensor=NULL)# NULL means all sensorsped_run#> # A tibble: 912,288 x 5#>   Sensor                      Date_Time           Date        Time Count#>   <chr>                       <dttm>              <date>     <int> <int>#> 1 Alfred Place                2016-01-01 00:00:00 2016-01-01     0    NA#> 2 Birrarung Marr              2016-01-01 00:00:00 2016-01-01     0  1405#> 3 Bourke St-Russell St (West) 2016-01-01 00:00:00 2016-01-01     0  1900#> 4 Bourke Street Mall (North)  2016-01-01 00:00:00 2016-01-01     0   461#> 5 Bourke Street Mall (South)  2016-01-01 00:00:00 2016-01-01     0   883#> # … with 912,283 more rows

There are missing values (i.e. NA) in the dataset. By settingna.rm = TRUE in both functions, missing values will be removed.

Here’s an example to useggplot2 for visualisation:

library(ggplot2)ggplot(data= subset(ped_walk,Sensor=="Melbourne Central"))+  geom_line(aes(x=Date_Time,y=Count))

To access minute by minute directional pedestrian counts for the lasthour, please check out themelb_walk_directional().

It’s recommended to include an application token inmelb_walk_fast(app_token = "YOUR-APP-TOKEN"), which you can sign uphere.

Shiny app

The functionmelb_shine() launches a shiny app to give a glimpse ofthe data. It provides two basic plots: one is an overlaying time seriesplot, and the other is a dot plot indicating missing values. Below is ascreen-shot of the shiny app.

About

R package to provide API to Melbourne pedestrian data

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp