View source: R/add_variable_to_data_set.R
| add_granularity_geo_to_data_set | R Documentation |
Derives the geographic granularity label from the location_code column
and adds it as a new granularity_geo column, modifying x in place.
When location_reference is NULL the granularity is inferred from the
location code prefix; when a reference table is supplied, it is looked up
directly.
add_granularity_geo_to_data_set(x, location_reference = NULL)
x |
A data.table containing a column named |
location_reference |
A data.table with columns |
x, invisibly, with the granularity_geo column added or updated.
library(data.table)
data <- data.table(location_code = c("nation_nor", "county_nor03", "blah"))
csdata::add_granularity_geo_to_data_set(data)
print(data)
library(data.table)
data <- data.table(location_code = c("nation_nor", "county_nor03", "blah"))
csdata::add_granularity_geo_to_data_set(data, location_reference = csdata::nor_locations_names())
print(data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.