Skip to contents

boxplots show range of scores here vs range in US overall

Usage

plot_boxplot_ratios(
  x,
  selected_dvar_colname = varlist2names("names_d")[1],
  selected_dvar_nicename = selected_dvar_colname,
  towhat_nicename = "US average",
  maxratio = 5,
  wheretext = "Near"
)

Arguments

x

ratios derived from a data.frame that is the output of ejscreen analysis, for example:

df <- ejscreenit(testpoints_5)$table

df <- testoutput_ejscreenapi_plus_5

x <- calc_ratios_to_avg(df)$ratios_d

selected_dvar_colname

default is the first column name of x, such as "Demog.Index" if given a table with just ratios that are named as regular indicators, as with output of calc_ratios_to_avg()$ratios_d, but it tries to figure out if ratios are available and what the base name is in case output of ejamit() was provided.

selected_dvar_nicename

default is the "short" name of selected_dvar_colname as converted using fixcolnames()

towhat_nicename

default is "US average"

maxratio

largest ratio to plot in case of outliers, so plot looks better

wheretext

Use in plot subtitle. Default is "Near" but could be "Within 5km of" for example. If it is a number, n, it will set wheretext to "Within n miles of"

Value

same format as output of ggplot2::ggplot()

Details

See ejam2boxplot_ratios() now for ratios plots.

See plot_boxplot_pctiles() now espec. for percentiles.

IMPORTANTLY, NOTE this uses the ratio at each site USING THE AVERAGE RESIDENT AT THAT SITE, SO A BOXPLOT SHOWS ONE DOT PER SITE AND THE BOXPLOT IS NOT POP WTD MEANING IT SHOWS THE MEDIAN AND 75TH PERCENTILE SITE NOT RESIDENT, ETC.

This function originally was used for ejscreenit() output, and was just a quick interim solution that could be replaced. It assumed colnames were not r variable names.

To communicate whether this is skewed to the right (more high scores than might expect) also could say that X% OF SITES OR PEOPLE have scores in top Y% of US range, >= 100-Y percentile. e.g., 20% of these sites have scores at least in the top 5% of US scores (which is more/less than one might expect

  • leaving aside statistical significance ie whether this could be by chance if sites were randomly picked from US block groups or people's bg scores)

Examples

  # x <- testoutput_ejscreenit_50$table # or
  x <- testoutput_ejscreenapi_plus_5
  myradius <- x$radius.miles[1]
  plot_boxplot_ratios(calc_ratios_to_avg(x)$ratios_d, wheretext = myradius)
  #plot_boxplot_ratios(calc_ratios_to_avg(x)$ratios_e, wheretext = myradius)