overlaps | R Documentation |
This is just a convenient way to compare two sets (vectors) that overlap, to count how many are in each set, how many are in a not b, in b not a, in both, etc.
overlaps(
a,
b,
values = FALSE,
ab_names = c("a", "b"),
ab_colors = c("gray", "orange"),
venn_draw = TRUE,
venn_save = FALSE,
filename = "venn.png",
overlapcount = NULL,
...
)
a |
Required vector, such as list of FIPS character codes. |
b |
Required vector |
values |
Default is FALSE. If TRUE, output is logical data.frame with union of only the unique elements as rownames, indicating which of those meet each criterion. |
ab_names |
optional vector of 2 names to use as labels if drawing Venn |
ab_colors |
optional vector of 2 colors if drawing Venn |
venn_draw |
optional, whether to plot the Venn in viewer window |
venn_save |
optional, whether to save a png of the Venn plot |
filename |
optional, name of png file to use if venn_save is TRUE |
overlapcount |
if number is provided, a and b are interpreted as counts and overlapcount is interpreted as count of intersection, and parameter called values is ignored. |
... |
optional, passed to |
Returns a data.frame of counts by default, formatted for viewing as a small table.
If values = TRUE, returns a larger data.frame (see values
parameter).
If overlapcount provided, returns nothing. See examples.
setdiff2()
, dplyr::setops()
, plotrix::intersectDiagram()
overlaps(11022+48541, 8748+48541, overlapcount= 48541, ab_names = c(
"59,563 block groups have\n any Suppl EJ index\n >=90th pctile in State",
"57,289 block groups have\n any Suppl EJ index\n >=90th pctile in US"),
ab_colors = c("lightblue", "yellow"))
overlaps( c('Selectric 251','Selectric 245'),
c('Selectric 245','Selectric 255','Selectric 255'))
overlaps( c('Selectric 251','Selectric 245'),
c('Selectric 245','Selectric 255','Selectric 255'), values = TRUE)
overlaps(state.abb[1:3], state.abb[3:4])
colSums( overlaps(state.abb[1:3], state.abb[3:4], values = TRUE)[,-1] )
colSums( overlaps(state.abb[1:3], state.abb[c(3:4,4,4,4,4,4)],
values = TRUE)[,-1] )
overlaps(state.abb[1:3], state.abb[c(3:4,4,4,4,4,4)])
overlaps(state.abb[1:3], state.abb[3:4], values = TRUE)
## Not run:
overlaps(ejanalysis::get.state.info()$ST, state.abb)
data(fips.state, package='acs')
overlaps(lead.zeroes(fips.state$STATE,2),
ejanalysis::get.state.info()$FIPS.ST)
data(fips.county, package='acs')
overlaps(ejanalysis::get.county.info()$FIPS.COUNTY,
paste(analyze.stuff::lead.zeroes(fips.county$State.ANSI,2),
analyze.stuff::lead.zeroes(fips.county$County.ANSI,3), sep=''))
colSums( overlaps(ejanalysis::get.state.info()$ST, c(999, state.abb),
values = TRUE)[ , 2:8])
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.