Clinton

Clinton


Home
About
My Data Sets

© 2019

datagovsgR is complete!

It’s been a long time since I posted as life has been mostly work since I stopped being a student. During this December break, I decided to spend some time to complete the R package which I had been working on but had not complete. Also, it was taken off CRAN for a quite some time as there was some issue with data.table.

It’s finally version 1.0.0 as I have added in support for the last 2 apis and now the package supports all apis on data.gov.sg, less the IPOS ones which does not appear to be returning any data regardless of date and time.

Overall, it’s been a great experience touching R again, and version 1 is on its way to CRAN! Hopefully whoever is using the package finds it useful! This R package started out as a module’s homework under QMSS, and I think T Brambor has single handedly supported a significant number of packages to CRAN with his class.

As 2022 comes to and end, looking forward to more projects in 2023!

Using datagovsgR

The API provided by data.gov.sg does not require an API key and hence the package is able to query the relevant information directly. Below are two examples of the functions within the package

PSI

The psi function is shown below, which returns 12 different psi measures across 5 sectors in Singapore for a given date and time. The user is able query a specific date and time, or for current available information by omitting the parameter.

psi(date_time = "2019-11-08T17:30:02")
#> Closest timestamp: 2019-11-08T17:00:00+08:00
#>                psi_measures  west national  east central south north
#>  1             o3_sub_index 12.00    20.00 13.00   20.00 13.00 17.00
#>  2  pm10_twenty_four_hourly 33.00    39.00 35.00   29.00 39.00 30.00
#>  3           pm10_sub_index 33.00    39.00 35.00   29.00 39.00 30.00
#>  4             co_sub_index  4.00     9.00  9.00    2.00  4.00  5.00
#>  5  pm25_twenty_four_hourly 21.00    22.00 21.00   18.00 22.00 19.00
#>  6            so2_sub_index  8.00     8.00  3.00    3.00  8.00  5.00
#>  7        co_eight_hour_max  0.43     0.95  0.95    0.24  0.39  0.52
#>  8         no2_one_hour_max 12.00    33.00 27.00   14.00 33.00 20.00
#>  9   so2_twenty_four_hourly 13.00    13.00  5.00    4.00 13.00  8.00
#> 10           pm25_sub_index 61.00    63.00 61.00   57.00 63.00 59.00
#> 11   psi_twenty_four_hourly 61.00    63.00 61.00   57.00 63.00 59.00
#> 12        o3_eight_hour_max 27.00    48.00 32.00   48.00 30.00 41.00