Created
April 8, 2016 13:27
-
-
Save nutterb/f9fb89d35766022b0f75c90b24d45033 to your computer and use it in GitHub Desktop.
When I'm developing packages, sometimes I just want to find the files that contain a particular variable. This helps me search all of the files for the existence of a string pattern.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
directorySearch <- function(dir, pattern, ...) | |
{ | |
files <- list.files(dir) | |
suppressWarnings( | |
Code <- lapply(file.path(dir, files), | |
readLines) | |
) | |
files[vapply(Code, | |
function(x, pattern, ...) any(grepl(pattern, x, ...)), | |
logical(1), | |
pattern = pattern, | |
...)] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment