scriptSearch {BurStMisc} | R Documentation |
Search R scripts for text
Description
Returns a list of text matches in the scripts in a directory.
Usage
scriptSearch(pattern, path = ".", subdirs = TRUE, suffix = "\\.[rR]$",
commentsIncluded = FALSE, ..., verbose = FALSE)
Arguments
pattern |
character string containing a regular expression
(this is the argument of the same name for |
path |
a character string giving the (relative) path of the directory holding the R scripts. |
subdirs |
logical value: if |
suffix |
a character string restricting the files to be searched. |
commentsIncluded |
logical value: if |
... |
additional arguments to |
verbose |
logical value: if |
Details
The default suffix
argument restricts the search to R scripts.
An R script is considered to be a file that ends in dot-R, where the
"R" can be lowercase or uppercase.
Value
a list: the names are equal to the file names containing matches, and each component is a character vector of the whitespace-trimmed lines in the file that match the pattern.
Limitations
Using commentsIncluded=FALSE
does not preclude a match being
declared when it is in a comment not starting the line.
Author(s)
Pat Burns
See Also
Examples
## Not run:
scriptSearch("list.files")
scriptSearch("garch", "~/../burns-stat3/webpages/blog")
# search for an assignment
# ' *' means zero or more spaces
scriptSearch("specialObject *<- ", "~/myScriptDirectory", subdirs=FALSE)
# search COBOL files
scriptSearch("blah", suffix="\\.cbl$")
## End(Not run)