gsubInOneFolder: Replace text in all scripts from a folder

Description Usage Arguments Details Value Author(s) Examples

View source: R/text_manipulation_in_scripts.r

Description

Opens all files with a .r or .R extension in the directory and runs a gsub.

Usage

1
2
3
4
5
6
7
8
9
gsubInOneFolder(
  fullPath,
  pattern,
  replacement,
  recursive = FALSE,
  newPath = NULL,
  userCheck = TRUE,
  ignore.case = FALSE
)

Arguments

fullPath

A character vector with the path to the folder containing the scripts to modify.

pattern

passed to base::gsub.

replacement

passed to base::gsub.

recursive

logical. Passed to base::list.files. Should the listing recurse into directories?

newPath

description

userCheck

Logical, default = TRUE. Matches are shown to check the pattern 'accuracy' before replacement.

ignore.case

logical. FALSE for case-sensitive matches. Default is TRUE.

Details

If not working inside an R project, path has to be complete from root.

Value

A data.frame with the number of matches in each file.

Author(s)

Alban Sagouis

Examples

1
2
## Not run: gsubInOneFolder('./R', pattern = 'sum', replacement = 'sumNA')
## Not run: gsubInOneFolder('.',  pattern = 'read.csv', replacement = 'data.table::fread')

AlbanSagouis/myToolbox documentation built on Feb. 1, 2021, 1:08 p.m.