View source: R/proxistat.rollup.R
proxistat.rollup | R Documentation |
Aggregate proximity statistics already calculated for each Census block, up to one summary for each Census block group. The resulting proximity score, distance to nearest single point, or count of nearby points is just the population-weighted mean of values in the blocks within a given block group.
proxistat.rollup(output, blocksfips, blocksfipsbg, blockspop)
output |
Required matrix of results from |
blocksfips |
Required character vector of 15-digit Census block FIPS codes (not numeric, must have leading zeroes as needed). |
blocksfipsbg |
Required character vector of 12-digit Census block group FIPS codes (not numeric, must have leading zeroes as needed). Same length and order as blocksfips. |
blockspop |
Required numeric vector of population counts in Census blocks. Same length and order as blocksfips. |
The population-weighted mean might not be the only statistic of interest.
To get the maximum count of sites near any single block in the block group, try aggregate(output[ , 'count.near'], by=list(blocks$FIPS.BG), FUN=max).
To get the shortest distance from any block in the block group to the nearest site, try aggregate(output[ , 'nearestone.d'], by=list(blocks$FIPS.BG), FUN=min).
To find out how many unique sites are within X km of the internal point of any block in the block group, for example,
is harder, because it requires retaining details on which sites were near a given block, i.e., much more data would be the input to an aggregating function.
Returns a data.frame with FIPS.BG and same fields proxistat can provide (depending on what is in the parameter called output): scores, nearestone.d, count.near, but with one row for each of the block groups defined by FIPS.BG. Units (miles or km) are unchanged from those used to create input parameters.
proxistat
and proxistat.chunked
to create proximity statistics,
and see get.distances
and get.distances.all
for distances between points, and
get.nearest
which finds the distance to the single nearest point
within a specified search radius instead of all topoints.
See also rollup
via http://ejanalysis.github.io/ejanalysis/
## Not run:
# require(Hmisc); require(data.table)
# require("devtools") # to obtain packages via devtools::github_install()
# These are on github.com/ejanalysis, e.g. https://github.com/ejanalysis/UScensus2010blocks
# require(analyze.stuff); require(ejanalysis)
# require(UScensus2010blocks) # for the get.blocks() function and dataset
# blocks <- UScensus2010blocks::get.blocks()
# bgp <- proxistat.rollup(output=output, blocksfips=blocks$fips, blocksfipsbg=blocks$FIPS.BG, blockspop=blocks$pop)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.