create_cooccurrence_matrix: Create a co-occurrence matrix

View source: R/create_cooccurrence_matrix.R

create_cooccurrence_matrixR Documentation

Create a co-occurrence matrix

Description

This function creates a co-occurrence matrix based on one or more coded sources. Optionally, it plots a heatmap, simply by calling the stats::heatmap() function on that matrix.

Usage

create_cooccurrence_matrix(
  x,
  codes = x$convenience$codingLeaves,
  plotHeatmap = FALSE
)

Arguments

x

The parsed source(s) as provided by rock::parse_source or rock::parse_sources.

codes

The codes to include; by default, takes all codes.

plotHeatmap

Whether to plot the heatmap.

Value

The co-occurrence matrix; a matrix.

Examples

### Get path to example source
examplePath <-
  system.file("extdata", package="rock");

### Parse a selection of example sources in that directory
parsedExamples <-
  rock::parse_sources(
    examplePath,
    regex = "(test|example)(.txt|.rock)"
  );

### Create cooccurrence matrix
rock::create_cooccurrence_matrix(parsedExamples);


rock documentation built on Dec. 28, 2022, 1:55 a.m.