findInFiles {findInFiles}R Documentation

Find pattern in files

Description

Find a pattern in some files. The functions findInFiles and fif are the same, and fifR(...) is the same as findInFiles(extensions = "R", ...).

Usage

findInFiles(
  extensions,
  pattern,
  depth = NULL,
  maxCountPerFile = NULL,
  maxCount = NULL,
  wholeWord = FALSE,
  ignoreCase = FALSE,
  extended = FALSE,
  fixed = FALSE,
  perl = FALSE,
  includePattern = NULL,
  excludePattern = NULL,
  excludeFoldersPattern = NULL,
  moreOptions = NULL,
  root = ".",
  output = "viewer",
  elementId = NULL
)

fif(
  extensions,
  pattern,
  depth = NULL,
  maxCountPerFile = NULL,
  maxCount = NULL,
  wholeWord = FALSE,
  ignoreCase = FALSE,
  extended = FALSE,
  fixed = FALSE,
  perl = FALSE,
  includePattern = NULL,
  excludePattern = NULL,
  excludeFoldersPattern = NULL,
  moreOptions = NULL,
  root = ".",
  output = "viewer",
  elementId = NULL
)

fifR(...)

Arguments

extensions

extension(s) of the files to include in the search (case-sensitive), e.g. "R" or c("R", "Rmd"), or "*" to search in all files

pattern

pattern to search for, a regular expression, e.g. "function" or "^function", or a string if fixed=TRUE; by default the pattern is considered as a basic regular expression, but this can be changed to an extended regular expression by setting extended=TRUE or to a Perl regular expression by setting perl=TRUE

depth

depth of the search, NULL or a negative number for an entire recursive search (subdirectories, subdirectories of subdirectories, etc.), otherwise a positive integer: 0 to search in the root directory only, 1 to search in the root directory and its subdirectories, etc.

maxCountPerFile

maximum number of results per file, NULL for an unlimited number, otherwise a positive integer; when an integer m is supplied, grep stops to search in each file after it finds m results

maxCount

maximum number of results, NULL for an unlimited number, otherwise a positive integer; supplying an integer m just truncates the output, it does not stop grep after m results are found (so there is no gain of efficiency)

wholeWord

logical, whether to match the whole pattern

ignoreCase

logical, whether to ignore the case

extended

logical, whether the pattern given in the pattern is an extended regular expression; if TRUE, you can search for multiple patterns by passing a string like "(pattern1|pattern2|...)" to the pattern argument

fixed

logical, whether the pattern given in the pattern argument is a string to be matched as is, or, to search for multiple patterns, multiple strings separated by "\n"

perl

logical, whether the pattern given in the pattern argument is a Perl regular expression; if TRUE, you can search for multiple patterns by passing a string like "(pattern1|pattern2|...)" to the pattern argument

includePattern

this argument is ignored if depth is not a positive integer; it must be a pattern or a vector of patterns, and only the files whose name matches this pattern or one of these patterns will be included in the search

excludePattern

a pattern or a vector of patterns; files and folders whose name matches this pattern or one of these patterns will be excluded from search

excludeFoldersPattern

a pattern or a vector of patterns; folders whose name matches this pattern or one of these patterns will be excluded from search

moreOptions

additional options passed to the grep command, for grep experts

root

path to the root directory to search from

output

one of "viewer", "tibble" or "viewer+tibble"; set "tibble" to get a tibble, "viewer" to get a htmlwidget, and "viewer+tibble" to get a htmlwidget from which you can extract a tibble with the function FIF2tibble

elementId

a HTML id, usually useless

...

arguments other than extensions passed to findInFiles

Value

A tibble if output="tibble", otherwise a htmlwidget object.

Examples

library(findInFiles)
folder <- system.file("example", package = "findInFiles")
findInFiles("R", "function", root = folder)

findInFiles("R", "function", root = folder, output = "tibble")

fif <- findInFiles("R", "function", root = folder, output = "viewer+tibble")
FIF2tibble(fif)
FIF2dataframe(fif)
fif

folder <- system.file("www", "shared", package = "shiny")
findInFiles(
  "css", "color", root = folder,
  excludePattern = c("*.min.css", "selectize*", "shiny*")
)

[Package findInFiles version 0.5.0 Index]