North Carolina Map
# Codes are the county FIPS codes and values are some number that will determine the color of the county on the map
# Lower numbers are lighter color and higher numbers are darker color
county_values <- list(
codes=c('37001', '37003', '37005', '37007', '37009', '37011', '37013', '37015', '37017', '37019', '37021', '37023', '37025', '37027', '37029', '37031', '37033', '37035', '37037', '37039', '37041', '37043', '37045', '37047', '37049', '37051', '37053', '37055', '37057', '37059', '37061', '37063', '37065', '37067', '37069', '37071', '37073', '37075', '37077', '37079', '37081', '37083', '37085', '37087', '37089', '37091', '37093', '37095', '37097', '37099', '37101', '37103', '37105', '37107', '37109', '37111', '37113', '37115', '37117', '37119', '37121', '37123', '37125', '37127', '37129', '37131', '37133', '37135', '37137', '37139', '37141', '37143', '37145', '37147', '37149', '37151', '37153', '37155', '37157', '37159', '37161', '37163', '37165', '37167', '37169', '37171', '37173', '37175', '37177', '37179', '37181', '37183', '37185', '37187', '37189', '37191', '37193', '37195', '37197', '37199'),
values=c(57279, 12270, 4232, 11241, 9514, 5557, 18312, 8751, 15199, 38663, 81809, 33967, 65532, 32679, 2388, 20183, 9066, 55655, 16439, 12019, 5760, 4550, 45386, 26521, 34350, 138979, 6345, 9877, 58769, 11810, 24181, 94019, 28212, 127744, 22199, 85311, 3875, 3867, 18202, 8074, 181542, 25465, 44500, 22969, 33396, 10238, 21392, 1817, 51173, 13156, 70232, 3906, 24383, 26991, 25258, 18578, 13640, 8265, 9746, 351568, 5698, 11602, 25289, 39041, 60365, 8794, 62800, 26468, 4043, 16576, 20808, 4852, 14443, 60351, 5999, 53355, 23759, 72368, 35941, 54424, 28071, 29584, 18643, 21515, 14287, 28938, 7445, 10472, 1544, 56833, 24998, 231025, 8501, 5464, 8611, 51012, 25788, 35913, 12391, 6795)
)
nswidgets::create_nc_map(region_data = county_values, value_label = 'members', map_key_note = 'as of July 2019')
North Carolina Map - Zip Level
# Codes are the zip / postal code
nc_zip_pop <- read.csv('./data/nc_zip_pop.csv')
zip_values <- list(
codes=nc_zip_pop$codes,
values=nc_zip_pop$values
)
nswidgets::create_nc_map(
region_data = zip_values,
region_level = 'zip',
value_label = 'population',
map_key_note = 'as of 2015 - source: IRS',
scale_options = list(
type = "symlog",
# Controls how quickly/slowly the logarithmic curve reaches the darkest color. The default is 1.
constant = 10000
)
)
United States State Map
# Codes are the state FIPS codes (by default) and values are some number that will determine the color of the state on the map
# Lower numbers are lighter color and higher numbers are darker color
state_values <- list(
codes=c('01','02','04','05','06','08','09','10','12','13','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','44','45','46','47','48','49','50','51','53','54','55','56'),
values=c(4887871,737438,7171646,3013825,39557045,5695564,3572665,967171,21299325,10519475,1420491,1754208,12741080,6691878,3156145,2911505,4468402,4659978,1338404,6042718,6902149,9995915,5611179,2986530,6126452,1062305,1929268,3034392,1356458,8908520,2095428,19542209,10383620,760077,11689442,3943079,4190713,12807060,1057315,5084127,882235,6770010,28701845,3161105,626299,8517685,7535591,1805832,5813568,577737)
)
nswidgets::create_us_map(region_data = state_values, value_label = 'population', map_key_note = 'US Census Pop Est 2018', color_range = 'blue')
United States State Map
# Codes can be two letter codes instead of FIPS if you ask the widget nicely (iow, set the use_letter_codes = TRUE)
state_values <- list(
codes=c('CA', 'NC', 'TX', 'ME'),
values=c(4887871,737438,7171646,3013825)
)
nswidgets::create_us_map(region_data = state_values, use_letter_codes = TRUE, value_label = 'some number', color_range = 'blue')
Global Country Map
world_pop <- read.csv('./data/world_population.csv')
country_values <- list(
codes=world_pop$codes,
values=world_pop$values
)
nswidgets::create_global_map(region_data = country_values, use_letter_codes = TRUE, value_label = 'population', color_range = 'blue')
Diverging Scale Map
nc_codes <- c('37001', '37003', '37005', '37007', '37009', '37011', '37013', '37015', '37017', '37019', '37021', '37023', '37025', '37027', '37029', '37031', '37033', '37035', '37037', '37039', '37041', '37043', '37045', '37047', '37049', '37051', '37053', '37055', '37057', '37059', '37061', '37063', '37065', '37067', '37069', '37071', '37073', '37075', '37077', '37079', '37081', '37083', '37085', '37087', '37089', '37091', '37093', '37095', '37097', '37099', '37101', '37103', '37105', '37107', '37109', '37111', '37113', '37115', '37117', '37119', '37121', '37123', '37125', '37127', '37129', '37131', '37133', '37135', '37137', '37139', '37141', '37143', '37145', '37147', '37149', '37151', '37153', '37155', '37157', '37159', '37161', '37163', '37165', '37167', '37169', '37171', '37173', '37175', '37177', '37179', '37181', '37183', '37185', '37187', '37189', '37191', '37193', '37195', '37197', '37199')
region_data <- list(codes=nc_codes, values=sample(-100:200, length(nc_codes)))
nswidgets::create_nc_map(
region_data = region_data,
value_label = 'random number',
map_key_note = 'random data',
scale_options = list(
type = 'divergingSymlog',
# Controls how quickly/slowly the logarithmic curve reaches the darkest color. The default is 1.
constant = 1000
)
)