Package 'findR'

Title: Find Code Snippets, R Scripts, R Markdown, PDF and Text Files with Pattern Matching
Description: Scans all directories and subdirectories of a path for code snippets, R scripts, R Markdown, PDF or text files containing a specific pattern. Files found can be copied to a new folder.
Authors: David Zumbach [aut, cre]
Maintainer: David Zumbach <[email protected]>
License: GPL-3
Version: 0.2.1
Built: 2024-11-23 02:45:33 UTC
Source: https://github.com/zumbov2/findr

Help Index


Find PDF files by content with pattern matching

Description

findPDF scans all directories and subdirectories of a given path for PDF files (.pdf) containing a specific pattern. Hits can be copied to a new folder.

Usage

findPDF(path = ".", pattern = "Hello World", case.sensitive = TRUE,
  show.results = TRUE, copy = FALSE, folder = "findPDF",
  overwrite = TRUE)

Arguments

path

a character vector, path to be scanned. The default corresponds to the working directory, getwd().

pattern

a pattern (regular expression) to search for.

case.sensitive

a logical value. If TRUE, pattern-matching is case-sensitive.

show.results

a logical value. If TRUE, results are printed after completion.

copy

a logical value. If TRUE, all matching PDF files are copied to folder.

folder

a character vector, path or name of new folder to copy matching PDF files to.

overwrite

a logical value. If TRUE, existing destination files are overwritten.

Examples

# Find all PDF files in the package folder that contain the name Hanna
findPDF(path = system.file(package = "findR"), pattern = "Hanna")

# Save results in a data frame and show hits
dt <- findPDF(path = system.file(package = "findR"), pattern = "Hanna", show.results = TRUE)
dt

Find R Markdown files by content with pattern matching

Description

findRmd scans all directories and subdirectories of a given path for R Markdown files (.Rmd) containing a specific pattern. Hits can be copied to a new folder.

Usage

findRmd(path = ".", pattern = "Hello World", case.sensitive = TRUE,
  show.results = TRUE, copy = FALSE, folder = "findRmd",
  overwrite = TRUE)

Arguments

path

a character vector, path to be scanned. The default corresponds to the working directory, getwd().

pattern

a pattern (regular expression) to search for.

case.sensitive

a logical value. If TRUE, pattern-matching is case-sensitive.

show.results

a logical value. If TRUE, results are printed after completion.

copy

a logical value. If TRUE, all matching R Markdown files are copied to folder.

folder

a character vector, path or name of new folder to copy matching R Markdown files to.

overwrite

a logical value. If TRUE, existing destination files are overwritten.

Examples

# Find all R Markdown files in the package folder that contain a ggplot bar chart
findRmd(path = system.file(package = "findR"), pattern = "geom_bar")

# Save results in a data frame and show hits
dt <- findRmd(path = system.file(package = "findR"), pattern = "geom_bar", show.results = TRUE)
dt

Find R scripts by content with pattern matching

Description

findRscript scans all directories and subdirectories of a given path for R scripts (.R) containing a specific pattern. Hits can be copied to a new folder.

Usage

findRscript(pattern = "Hello World", path = ".", case.sensitive = TRUE,
  comments = TRUE, show.results = TRUE, copy = FALSE,
  folder = "findRscript", overwrite = TRUE)

Arguments

pattern

a pattern (regular expression) to search for.

path

a character vector, path to be scanned. The default corresponds to the working directory, getwd().

case.sensitive

a logical value. If TRUE, pattern-matching is case-sensitive.

comments

a logical value. If TRUE, comments (lines starting with #) are included in the pattern-matching procedure.

show.results

a logical value. If TRUE, results are printed after completion.

copy

a logical value. If TRUE, all matching R scripts are copied to folder.

folder

a character vector, path or name of new folder to copy matching R scripts to.

overwrite

a logical value. If TRUE, existing destination files are overwritten.

Examples

# Find all Rscripts in the package folder that use the circlize package
findRscript(path = system.file(package = "findR"), pattern = "circlize")

# Save results in a data frame and show hits
dt <- findRscript(path = system.file(package = "findR"), pattern = "circlize", show.results = TRUE)
dt

Find text files by content with pattern matching

Description

findtxt scans all directories and subdirectories of a given path for text files (.txt) containing a specific pattern. Hits can be copied to a new folder.

Usage

findtxt(pattern = "Hello World", path = ".", case.sensitive = TRUE,
  show.results = TRUE, copy = FALSE, folder = "findtxt",
  overwrite = TRUE)

Arguments

pattern

a pattern (regular expression) to search for.

path

a character vector, path to be scanned. The default corresponds to the working directory, getwd().

case.sensitive

a logical value. If TRUE, pattern-matching is case-sensitive.

show.results

a logical value. If TRUE, results are printed after completion.

copy

a logical value. If TRUE, all matching text files are copied to folder.

folder

a character vector, path or name of new folder to copy matching text files to.

overwrite

a logical value. If TRUE, existing destination files are overwritten.

Examples

# Find all text files in the package folder that contain the name Einstein
findtxt(path = system.file(package = "findR"), pattern = "Einstein")

# Save results in a data frame and show hits
dt <- findtxt(path = system.file(package = "findR"), pattern = "Einstein", show.results = TRUE)
dt

Find reminders on how to use a specific R function

Description

reminder scans all directories and subdirectories of a given path for files (.R, .Rmd, .txt) containing a specific R function and prints the corresponding lines of code.

Usage

reminder(func = "library", path = ".", before = 0, after = 0,
  stepwise = TRUE)

Arguments

func

a function to search for.

path

a character vector, path to be scanned. The default corresponds to the working directory, getwd().

before

integer. The number of lines to print before the function.

after

integer. The number of lines to print after the function.

stepwise

a logical value. If TRUE, examples are shown one by one using prompt.

Examples

# Find reminder on how to use the function chordDiagram
reminder(func = "chordDiagram", path = system.file(package = "findR"), stepwise = FALSE)