find_code: Find scripts containing specific code

Description Usage Arguments

View source: R/find_code.R

Description

Find all the R scripts in a directory that contain some code as defined in pattern. This is especially useful when functions are redesigned and have to be adjusted in all scripts where they are used.

Usage

1
2
find_code(directory, pattern, recursive = TRUE, count = FALSE,
  indices = NULL, ending = ".*[.](r|R|s|S|q)([.](lnk|LNK))*$")

Arguments

directory

A path to the directory containing the R scripts.

pattern

Pattern to look for.

The default interpretation is a regular expression, as described in stringi::stringi-search-regex. Control options with regex().

Match a fixed string (i.e. by comparing only bytes), using fixed(). This is fast, but approximate. Generally, for matching human text, you'll want coll() which respects character matching rules for the specified locale.

Match character, word, line and sentence boundaries with boundary(). An empty pattern, "", is equivalent to boundary("character").

recursive

If TRUE, subdirectories are recursively searched for R scripts.

count

If TRUE, a vector with the number of occurences per script is returned. If FALSE, a character vector with the scripts containing at least one occurence is returned.

indices

Integer vector specifying the indices of lines to be searched in each script. This is useful, if you get an Shiny error indicating the line in which the error occured, but not the script. If NULL all lines of each script get searched.


DavidBarke/QWUtils documentation built on Jan. 13, 2020, 11:52 a.m.