Skip to contents

This function creates a heat map with class instances (or sources) in rows and codes in columns, coloring each cell as a function of how often that code occurs in that class instance or source.

Usage

code_by_classInstance_heatmap(
  x,
  wrapLabels = 80,
  classId = "tssid",
  codesRegex = ".*",
  classInstanceRegex = ".*",
  classInstanceLab = NULL,
  codeLab = NULL,
  freqLab = "Count",
  plotTitle = "Heatmap",
  fillScale = ggplot2::scale_fill_viridis_c(),
  theme = ggplot2::theme_minimal()
)

Arguments

x

The object with the parsed coded source(s) as resulting from a call to parse_source() or parse_sources().

wrapLabels

Whether to wrap the labels; if not NULL, the number of character to wrap at.

classId

The identifier of the class for which the class instances should form the rows (the class identifier is the bit to the left of the = or : in class instance codings).

codesRegex

A regular expression specifying which codes identifiers to select for the columns.

classInstanceRegex

A regular expression specifying which class instance identifiers to select for the rows.

classInstanceLab

Labels to use for the rows (NULL to omit the label).

codeLab

Labels to use for the columns (NULL to omit the label).

freqLab

Labels to use for the cell colors (NULL to omit the label).

plotTitle

The title to use for the plot

fillScale

Convenient way to specify the fill scale (the colours)

theme

Convenient way to specify the ggplot2::ggplot() theme.

Value

The heatmap as a ggplot2 plot.

Examples

examplePath <-
  file.path(
    system.file(package="rock"), 'extdata'
  );

parsedSources <- rock::parse_sources(
  examplePath,
  regex = "example-[123].rock"
);
#> Warning: For instance '1' of class 'caseId', attribute 'age' has different values: '60s' & '50s'. Taking the first element: '60s'.
#> Warning: For instance '2' of class 'caseId', attribute 'age' has different values: '20s' & '30s'. Taking the first element: '20s'.
#> Warning: For instance '1' of class 'caseId', attribute 'age' has different values: '60s' & '50s'. Taking the first element: '60s'.
#> Warning: For instance '2' of class 'caseId', attribute 'age' has different values: '20s' & '30s'. Taking the first element: '20s'.

### If no TSSIDs were configures, you can use
### source filenames instead like this:
rock::code_by_classInstance_heatmap(
  parsedSources,
  classId = "originalSource"
);