View source: R/get_pop_queries.R
get_pop_queries | R Documentation |
This function is a wrapper for the Population Query API. It allows for querying of multiple Popquery data types for multiple towns and years.
get_pop_queries( token, data_types, planning_areas, years, gender = NULL, parallel = FALSE )
token |
User's API token. This can be retrieved using |
data_types |
Type of data to be retrieved, should correspond to one of the API endpoints. E.g. to get economic status data, |
planning_areas |
Town for which the data should be retrieved. |
years |
Year for which the data should be retrieved. |
gender |
Optional, if specified only records for that gender will be returned. This parameter is only valid for the |
parallel |
Default = |
A tibble with each row representing a town in a particular year for a particular gender, and columns with the variables returned by the API endpoint. If any API call returns no data, the values will be NA but the row will be returned. However, if all data_types do not return data for that town and year, no row will be returned for it.
# output with no NA ## Not run: get_pop_queries(token, c("getOccupation", "getLanguageLiterate"), c("Bedok", "Yishun"), "2010") ## End(Not run) ## Not run: get_pop_queries(token, c("getEconomicStatus", "getEthnicGroup"), "Yishun", "2010", "female") ## End(Not run) ## note behaviour if data types is a mix of those that accept gender params ### only total will have all records ## Not run: get_pop_queries(token, c("getEconomicStatus", "getOccupation", "getLanguageLiterate"), "Bedok", "2010") ## End(Not run) ### data type that does not accept gender params will be in gender = Total ## Not run: get_pop_queries(token, c("getEconomicStatus", "getOccupation", "getLanguageLiterate"), "Bedok", "2010", gender = "female") ## End(Not run) # output with some town-year queries without record due to no data # warning message will show data_type/town/year/gender for which an error occurred ## Not run: get_pop_queries(token, c("getEconomicStatus", "getOccupation"), "Bedok", c("2010", "2012")) ## End(Not run) # no records for 2012
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.