# Set the default code chunk options for this document:
knitr::opts_chunk$set(echo = FALSE) # Don't print code itself.
knitr::opts_chunk$set(message = FALSE) # Don't print output messages.
knitr::opts_chunk$set(include = TRUE) # Do run code chunks.
knitr::opts_chunk$set(fig.width = 8) # Set the default image width wide enough so that it doesn't get cut off.
knitr::opts_chunk$set(fig.height = 6)
knitr::opts_chunk$set(fig.align="center")
knitr::opts_chunk$set(dev = 'png') # Set the default image writer to PDF
options(digits=2) # Use two decimal places by default.
knitr::opts_chunk$set(cache = FALSE)
vectors_to_use <- veccompare::example.vectors.list

Information about the maps

Note that results = "asis" is set in the code chunks below. This is necessary for output that is printed with the cat_immediately = TRUE option (or that is printed with cat(...) generally).

veccompare::compare.vectors.and.return.text.analysis.of.overlap(
    vectors_to_use,
    degrees_of_comparison_to_include = c(1),
    cat_immediately = TRUE,
    viewport_npc_width_height_for_images = 0.7,
    base_heading_level_to_use = 2
)

2-Way Comparisons Graphical and Tabular Summaries

The two-way comparisons can be summerized visually and tabularly in several ways.

First, we present a matrix showing decimal percentage overlap (i.e., "0.23" means "23%") between each pair of maps. This table is intended to be read with row names first, in this form:} "[row title] overlaps with [column title] [cell value] percent."

veccompare::summarize.two.way.comparisons.percentage.overlap(
    vectors_to_use,
    output_type = "matrix_plot"
)

The table above can also be read in the form below (reading across each row: [column one] overlaps with [column two] [column three] percent. As above, we present decimal percentages (i.e., "0.23" means "23%"):

pander::pandoc.table(
    veccompare::summarize.two.way.comparisons.percentage.overlap(
        vectors_to_use,
        output_type = "table",
        melt_table = TRUE
    ),
    split.cells = 15,
    split.tables = Inf,
    justify = c('center'),
    style = 'multiline'
)

Finally, we can create a network graph of all two-way comparisons between maps. Higher overlap is represented with darker lines. Maps are sized based on their relative numbers of items. Relationship lines are directed -- the arrow flows in the direction of overlap ("[map one] --> overlaps [line label] percent with --> [map two]").

This graph only shows relationships at or above 20% overlap.

veccompare::summarize.two.way.comparisons.percentage.overlap(
    vectors_to_use,
    output_type = "network_graph",
    network_graph_minimum = .2
)
# We can now get all comparisons between the vectors, from 2-way up to 6-way:

veccompare::compare.vectors.and.return.text.analysis.of.overlap(
    vectors_to_use,
    degrees_of_comparison_to_include = 2:length(vectors_to_use),
    cat_immediately = TRUE,
    draw_venn_diagrams = TRUE,
    viewport_npc_width_height_for_images = 0.65, # If venn diagrams are getting cut off, this number can be lowered (for example, to 0.7)
    base_heading_level_to_use = 1
)


publicus/r-veccompare documentation built on May 10, 2019, 1:18 p.m.