ejscreen.rollup: Aggregate EJSCREEN Dataset at Lower Resolution (e.g., Tracts)

View source: R/ejscreen.rollup.R

ejscreen.rollupR Documentation

Aggregate EJSCREEN Dataset at Lower Resolution (e.g., Tracts)

Description

Start with full EJSCREEN dataset at one resolution (typically block groups), and create aggregated data at a higher geographic scale (e.g., tracts or counties)

Usage

ejscreen.rollup(
  bg,
  fipsname = "FIPS.TRACT",
  scalename = "tracts",
  enames,
  folder = getwd(),
  sumnames,
  avgnames,
  wts,
  acsnames,
  checkfips,
  ...
)

Arguments

bg

Data.frame of raw data for environmental and demographic counts, one row per block group typically, one column per indicator.

fipsname

Default is 'FIPS.TRACT' - specifies colname of unique ID field FIPS used to group by. Can be FIPS.TRACT, FIPS.COUNTY, FIPS.ST, or REGION in default dataset.

scalename

***Not used. Default is 'tracts' - specifies text to use in naming the saved file.

enames

Default is names.e, the colnames of raw envt indicators in bg

folder

***Not used. Optional, default is getwd().

sumnames

Default is a vector of colnames in bg, those which should be rolled up as sums with na.rm=TRUE (e.g., sum of all block group population counts in the tract) including 'pop', 'povknownratio', 'age25up', 'hhlds', 'builtunits', 'mins', 'lowinc', 'lths', 'lingiso', 'under5', 'over64', 'VNI.eo', 'VNI.svi6', 'VDI.eo', 'VDI.svi6', 'hisp', 'nhaa', 'nhaiana', 'nhba', 'nhmulti', 'nhnhpia', 'nhotheralone', 'nhwa', 'nonmins', 'area', 'pre1960'

avgnames

Default is ejscreen::enames, a vector of colnames in bg, those which should be rolled up as weighted averages (e.g., pop wtd mean of air pollution level)

wts

Default is 'pop', the colname in bg specifying the field to use when calculating the weighted mean of all blockgroups in a tract, for example.

acsnames

Not used. Default is a vector of demographic colnames in bg, used in default ejscreen dataset (see code or ejscreenformulas)

checkfips

Whether to try to validate FIPS, passed to ejscreen.create(). See source for default.

...

Optional parameters to pass to ejscreen.create which uses formulas to create indicators from raw values.

Details

**default fieldnames are assumed for now. Uses ejscreen.create

Value

Returns a data.frame with ejscreen dataset of environmental and demographics indicators, and EJ Indexes, as raw values, US percentiles, but not text for popups. *** Output has one row per tract, county, state, or region, depending on what is specified.

See Also

ejscreen.create

Examples


 ## Not run: 
  # load("~/Dropbox/EJSCREEN/R analysis/bg 2015-04-22 Rnames plus subgroups.RData")
  # Do this for each of several levels of resolution
  #
  fipsnames <- c('FIPS.TRACT', 'FIPS.COUNTY', 'FIPS.ST', 'REGION')
  scalenames <- c('tracts', 'counties', 'states', 'regions')
  # or just for tracts, say this:
  #   fipsnames <- 'FIPS.TRACT'; scalenames <- 'tracts'

  for (i in 1:length(fipsnames)) {

  ##################################### #
  # Specify resolution of interest
  fipsname <- fipsnames[i] # 'FIPS.TRACT'
  scalename <- scalenames[i] # 'tracts'

  ##################################### #
  # Get results, using the function
  myrollup <- ejscreen.rollup(bg = bg, fipsname = fipsname)

  ##################################### #
  # Save results
  save(myrollup, file = paste('EJSCREEN 202o', scalename, 'data.RData') )
  write.csv(myrollup, row.names = FALSE, file = paste('EJSCREEN 2020', scalename, 'data.csv'))

  }
 
## End(Not run)


ejanalysis/ejscreen documentation built on April 2, 2024, 10:15 a.m.