Learn R Programming

choroplethr (version 3.6.1)

calculate_percent_change: Calculate the percentage change between two choroplethr dataframes.

Description

Merges df1 and df2 on column named "region", and computes percentage change from df1$value to df2$value. Result is in the new "value" column, and rounded to two digits.

Usage

calculate_percent_change(df1, df2)

Arguments

df1

A dataframe with columns named "region" and "value"

df2

A dataframe with columns named "region" and "value"

Examples

Run this code
# NOT RUN {
# load median age estimates from 2010 and 2015
data(df_state_age_2010)
data(df_state_age_2015)

df_age_diff = calculate_percent_change(df_state_age_2010, df_state_age_2015)
state_choropleth(df_age_diff, 
    title      = "Percent Change in Median Age, 2010-2015", 
    legend     = "Percent Change", 
    num_colors = 0)

# }

Run the code above in your browser using DataLab