get_string_constants_in_scripts: Get Frequency of String Constant Usage in R Scripts

View source: R/get_string_constants_in_scripts.R

get_string_constants_in_scriptsR Documentation

Get Frequency of String Constant Usage in R Scripts

Description

Get Frequency of String Constant Usage in R Scripts

Usage

get_string_constants_in_scripts(
  root,
  scripts = dir(root, "\\.[Rr]$", recursive = TRUE),
  two_version_check = TRUE,
  FUN = NULL
)

Arguments

root

path to folder in which to look for R scripts

scripts

optional. Paths to R scripts in which to search for string constants, relative to root

two_version_check

if TRUE (default), two different implementations of this function are used and the results are compared internally. Set this argument to FALSE to get the result as fast as possible.

FUN

optional. Function used to browse the code tree for string constants. If NULL (the default), kwb.code:::fetch_string_constants_1 is used.

Value

data frame with columns file_id (file identifier), string (string constant found in the file) and count (number of occurrences of the string counted in the file). The file identifier can be resolved to a full file name using the "file database" that is stored in the attribute "file_db".

Examples

root <- system.file(package = "kwb.code")
constants <- get_string_constants_in_scripts(root)

# Get paths to files from "file database" stored in attribute "file_db"
kwb.utils::getAttribute(constants, "file_db")


KWB-R/kwb.code documentation built on July 28, 2023, 5:57 p.m.