Crash: Retrieve the crash data with given month or year

CrashR Documentation

Retrieve the crash data with given month or year

Description

The function is used to download the crash data in Taiwan for the specific month or year.

Usage

Crash(access_token, crash, county, time, dtype="text", out=F)

Arguments

access_token

Your access token given by TDX platform. This can be derived from the function get_token().

crash

Please fill in the crash type, including A1 (crash with death within 24 hours), A2 (crash with injury-only or death over 24 hours), and A30 (crash with death over 30 days).

county

Please fill in the English county name. Checking out the appropriate county name in dataframe TDX_County.

time

The time (year-month) of the data. The format of time should be YYYY or YYYY-MM.

dtype

The class of data, including text (data frame) and sf (simple feature). The default value is text. Note that only crash data (T1) can be exported to shapefile, while person data (T2) remains text file.

out

If the result should be exported to the local, please fill in the directory. The default value is FALSE, which does not export the data. Note that the directory does not need to contain ".shp", ".csv", or ".txt". Note that if dtype is sf, then name of crash data (T2) would be ended with ".shp".

Value

The result would be a list containing crash data (T1) and person data (T2). Please use $T1 to retrieve crash data, and use $T2 to retrieve person data. Note that crash with death over 24 days (A30) only retrieves T2 data.

Columns and coding definition can be found by using $DEF.

Author(s)

Maintainer: Chia Jung, Yeh chia-jung.yeh@sydney.edu.au

Examples

#---download death-involved crash data of Taipei---#
crash_taipei=Crash(access_token, crash="A1", county="Taipei", time="2020-05", dtype="sf")
# retrieve crash data
crash_taipei$T1
# retrieve person data
crash_taipei$T2
# retrieve coding definition
crash_taipei$DEF

#---download injury-only crash data of Yilan---#
crash_yilan=Crash(access_token, crash="A2", county="YilanCounty", time="2021-06", dtype="sf", out="./crash_yilan")

ChiaJung-Yeh/NYCU_TDX documentation built on Nov. 25, 2024, 6:57 a.m.