count_occurrences: Count code occurrences

View source: R/count_occurrences.R

count_occurrencesR Documentation

Count code occurrences

Description

Count code occurrences

Usage

count_occurrences(x, codes = ".*", matchRegexAgainstPaths = TRUE)

Arguments

x

A parsed source(s) object.

codes

A regular expression to select codes to include, or, alternatively, a character vector with literal code idenfitiers.

matchRegexAgainstPaths

Whether to match the codes regular expression against the full code paths or only against the code identifier.

Value

A data.frame().

Examples

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

### Get a path to one example file
exampleFile <-
  file.path(examplePath, "example-3.rock");

### Load example source
loadedExample <- rock::parse_source(exampleFile);

### Show code occurrences
rock::count_occurrences(
  loadedExample
);

rock documentation built on June 14, 2025, 1:08 a.m.