gsubInOneScript: Replace text in one script

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/text_manipulation_in_scripts.r

Description

Open a file with a .r or .R extension and runs a gsub. No copy made except if newPath is specified, use at your own risks.

Usage

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

Arguments

fullPath

A character vector with the path to the script to modify.

pattern

passed to base::gsub.

replacement

passed to base::gsub.

newPath

Character vector. Used if a copy of the script should be created following this path.

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

The number of matches in the file.

Author(s)

Alban Sagouis

See Also

To search for text in any text file, see search_files.

Examples

1
2
## Not run: gsubInOneScript('DESCRIPTION','foobar@gmail.com','foobar@protonmail.com')
## Not run: gsubInOneScript('master.r','ifelse','data.table::fifelse')

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