find_replace: Find and replace text in object names in the global...

View source: R/find_replace.R

find_replaceR Documentation

Find and replace text in object names in the global environment

Description

Search all object names in the global environment for a regex pattern, and replace that pattern with specified text. This is actually done by creating copies of the objects with new names and deleting the original versions, which may consume large amounts of memory if the objects are large. By default, the user is prompted before objects are renamed.

Usage

find_replace(
  pattern, replace, pattern_find = NULL, ask = TRUE, envir = .GlobalEnv)

Arguments

pattern

character string, the regex pattern to replace. Passed to grep via ls_grep.

replace

character string, the text with which to replace pattern.

pattern_find

optional character string used to determine objects. Can be different from pattern, which allows renaming a subset of objects in the global environment. Defaults to NULL, which results in objects being matched with pattern.

ask

logical, whether to prompt the user before replacing objects. Defaults to TRUE.

envir

the name of the environment in which to make the changes. Defaults to the global environment, .GlobalEnv.


mjdufort/miscHelpers documentation built on Feb. 4, 2024, 7:44 p.m.