View source: R/get_pop_query.R
get_pop_query | R Documentation |
This function is a wrapper for the Population Query API. It only allows for querying of one data type (i.e. one of the API endpoints) for a particular town and year.
get_pop_query(token, data_type, planning_area, year, gender = NULL)
token |
User's API token. This can be retrieved using |
data_type |
Type of data to be retrieved, should correspond to one of the API endpoints. E.g. to get economic status data, |
planning_area |
Town for which the data should be retrieved. |
year |
Year for which the data should be retrieved. |
gender |
Optional, valid values include |
A tibble with 1 row and values for all the corresponding variables returned by the API endpoint.
If an error occurs, the function returns NULL and a warning message. This differs from the error handling of other functions in this package to prevent collective failure for get_pop_queries
.
# output with no NA
## Not run: get_pop_query(token, "getReligion", "Yishun", "2010")
## Not run: get_pop_query(token, "getModeOfTransportSchool", "Bishan", "2015", "female")
# if gender parameter is not specified, results for both genders and total will be returned
## Not run: get_pop_query(token, "getMaritalStatus", "Bedok", "2010")
## Not run: get_pop_query(token, "getEthnicGroup", "Bedok", "2010")
## Not run: get_pop_query(token, "getPopulationAgeGroup", "Bedok", "2010")
# output due to error
## Not run: get_pop_query(token, "getSpokenAtHome", "Bedok", "2043")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.