Skip to contents

Used to create input to boxplots_ratios() and can be used elsewhere now

Usage

calc_ratios_to_avg(
  out,
  evarnames = names_e,
  dvarnames = c(names_d, names_d_subgroups),
  zone.prefix = c("", "state.")[1],
  avg.evarnames = paste0(zone.prefix, "avg.", evarnames),
  avg.dvarnames = paste0(zone.prefix, "avg.", dvarnames)
)

Arguments

out

data.frame output from ejscreenapi_plus() or from ejscreenapi() or doaggregate(), one row per buffer or site, and columns for indicators named in evarnames, dvarnames, avg.evarnames, avg.dvarnames

evarnames

vector of variable names for environmental indicators in out, like pm, o3, etc.

dvarnames

vector of variable names for residential population indicators in out, such as pctlowinc

zone.prefix

us or state, must fit with colnames in out such as avg.pctlowinc and state.avg.pctlowinc

avg.evarnames

use only if user-specific variable names are in out, with defaults like avg.pm

avg.dvarnames

use only if user-specific variable names are in out, with defaults like avg.pctlowinc

Value

a list with ratios_d and ratios_e which are vectors of numbers the lengths of dvarnames and evarnames

Details

Note that colnames returned are same as input, not renamed to say "ratio" If names_d_subgroups are included, those means are not in API output from EJScreen so it gets the means from usastats or statestats

Examples

 out <- testoutput_ejscreenit_5$table # has long names
 names(out) <- fixcolnames(names(out1),'long','r')
 out2 <- testoutput_ejscreenapi_plus_5 # has r names already
 
 # these are data.frames, but the colnames are different:
 #   names like "Demog.Index" but they are ratios
 calc_ratios_to_avg(out)$ratios_d
 #   names like "ratio.to.avg.Demog.Index"
 out[ , names_d_ratio_to_avg] # needs EJAM for names_d_ratio_to_avg
 
 boxplots_ratios(calc_ratios_to_avg(out)$ratios_d,"pctlowinc","% low income", 
     wheretext="Within a mile of")