Learn R Programming

textAnnotatoR (version 1.0.1)

calculate_co_occurrences: Calculate code co-occurrences in annotations

Description

Analyzes text annotations to identify and count instances where different codes overlap or co-occur in the same text regions. Handles edge cases and provides error-safe operation.

Usage

calculate_co_occurrences(annotations)

Value

Table object containing frequencies of code pairs that co-occur, with code pair names as "code1 & code2"

Arguments

annotations

Data frame containing annotations with columns:

  • start: numeric, starting position of annotation

  • end: numeric, ending position of annotation

  • code: character, code identifier

Details

Co-occurrences are identified by finding overlapping text regions between different code annotations. The function sorts annotations by position and checks for overlaps between each pair of annotations.