freqTab_heatMaps.Rd
These functions create a heatmap showing the frequencies with which
specific possible entity values occur for the intersection of two entities -
or they create the underlying frequency table for the set of sources or just
one source. You usually only use heatMap_from_rxsProject
, which takes the
object with Rxs trees and creates a heatmap.
heatMap_from_freqTab(
freqTab,
rowOrder = rownames(freqTab),
colOrder = colnames(freqTab),
rowLab = "Row",
colLab = "Column",
freqLab = "Frequency",
plotTitle = paste0("Frequency Table for ", rowLab, " and ", colLab),
xLabelRotationAngle = 45,
legend.position = "right",
fillScale = ggplot2::scale_fill_viridis_c(),
theme = ggplot2::theme_minimal()
)
heatMap_from_rxsProject(
x,
rowRegex,
colRegex,
freqTabArgs = NULL,
rowOrder = NULL,
colOrder = NULL,
rowLab = "Row",
colLab = "Column",
freqLab = "Frequency",
plotTitle = paste0("Frequency Table for ", rowLab, " and ", colLab),
xLabelRotationAngle = 45,
legend.position = "right",
flattenValues = TRUE,
fillScale = ggplot2::scale_fill_viridis_c(),
theme = ggplot2::theme_minimal()
)
rxsProject_to_freqTab(
x,
rowRegex,
colRegex,
rowTargetValue = NULL,
colTargetValue = NULL,
fillValue = 0,
rowColMultiplicationFunction = `*`,
rowTargetFunction = `==`,
colTargetFunction = `==`,
aggregationFunction = `+`,
rowLabels = NULL,
colLabels = NULL,
rowOrder = NULL,
colOrder = NULL,
sortRowsAlphabetically = TRUE,
sortColsAlphabetically = TRUE,
includeValueListsOfMatch = TRUE,
flattenValues = TRUE,
excludeParentWhenValueListReturned = TRUE,
silent = metabefor::opts$get("silent")
)
rxsTreeList_to_freqTab(
x,
rowRegex,
colRegex,
rowTargetValue = NULL,
colTargetValue = NULL,
fillValue = 0,
rowColMultiplicationFunction = `*`,
rowTargetFunction = `==`,
colTargetFunction = `==`,
aggregationFunction = `+`,
rowLabels = NULL,
colLabels = NULL,
rowOrder = NULL,
colOrder = NULL,
sortRowsAlphabetically = TRUE,
sortColsAlphabetically = TRUE,
includeValueListsOfMatch = TRUE,
flattenValues = TRUE,
excludeParentWhenValueListReturned = TRUE,
silent = metabefor::opts$get("silent")
)
rxsTree_to_freqTab(
x,
rowRegex,
colRegex,
rowTargetValue = NULL,
colTargetValue = NULL,
valuePreprocessingFunction = vectorValue_to_valueList,
rowColMultiplicationFunction = `*`,
rowTargetFunction = `==`,
colTargetFunction = `==`,
rowLabels = NULL,
colLabels = NULL,
rowOrder = NULL,
colOrder = NULL,
sortRowsAlphabetically = TRUE,
sortColsAlphabetically = TRUE,
includeValueListsOfMatch = TRUE,
flattenValues = TRUE,
excludeParentWhenValueListReturned = TRUE,
silent = metabefor::opts$get("silent")
)
The frequency table (as produced
by rxsTreeList_to_freqTab
).
The order of the row and column entities/values.
The labels to use for the rows (y axis), columns (x axis), frequencies (fill), and the plot title to use.
The angel to rotate the labels on the X axis.
The position of the legend.
The fill scale to use.
The ggplot2 theme to use.
The Rxs object or the Rxs tree for which to produce the frequency table.
Regular expressions used to find the entities that will form the rows or columns
Arguments to pass to the frequency table functions.
Whether to flatten values that are vectors into single string values that represents those values, or not (in which case they remain vectors, and so single sources occur multiple times in the frequency table).
Value to consider a 'hit' for the row and column entities
The value to insert in rows or columns that have to be added because of inconsistencies between extraction scripts
The function to use to multiply the rows and columns into the matrix
Functions to use to compare,
the entity values found for the rows and columns to the target
values (e.g. ==
, >
, <
, etc).
The function to use to aggregate matrices
A names vector used to replace row and column labels; the indices (element names) should be the entity identifiers and the values the labels to use.
Whether to sort columns or rows alphabetically.
Whether to also include the value lists inside matching entities (useful for quickly selecting e.g. all results)
Whether, if an entity matches,
has a value list as value, and those value lists are returns (i.e.
includeValueListsOfMatch
is TRUE
), the parent entity (that matched
the regular expression) should be excluded.
Whether to be silent or chatty.
The function to use to preprocess values - only for advanced use.
A ggplot or a frequency table
The underlying frequency table is produced in a number of steps. First,
the values of the entities matching the regular expressions are obtained.
Second, the row and column target functions are applied to these values (as
first argument) and to the specified row and column target values (as second
argument). Then, the rowColMultiplicationFunction
is applied to the
result to obtain the value for the cell. Finally, if rxs_to_freqTab
is called, aggregationFunction
is called on the frequency tables of the
separate sources.
### Load an example Rxs Project
example_rxsProject_1 <- metabefor::example_rxsProject_1;
### Create a heatmap
metabefor::heatMap_from_rxsProject(
example_rxsProject_1,
"sourceAuthors",
"publicationYear",
rowLab = "Author",
colLab = "Year"
);
### Load an example Rxs Project
example_rxsProject_1 <- metabefor::example_rxsProject_1;
### Create a crosstable with frequencies
metabefor::rxsProject_to_freqTab(
example_rxsProject_1,
"sourceAuthors",
"publicationYear"
);
#> 2022 2021
#> Tiffany Aching 1 0
#> Samuel Vimes 0 1