sif | R Documentation |
sif()
recursively searches all files inside a directory for a term
(usually a regex pattern). If used interactively from RStudio it defaults
to displaying the results in the Markers pane. This is very similar to
RStudios find in files feature, but has the advantage that the search
results are also returned as a data.frame
that can be further processed.
sif(
pattern,
dir = ".",
markers = interactive() && requireNamespace("rstudioapi", quietly = TRUE),
fixed = FALSE,
case_sensitive = TRUE,
path_pattern = getOption("sifr.path_pattern"),
path_case_sensitive = FALSE,
recursive = TRUE,
encoding = "unknown"
)
sifkw(
keywords,
dir = ".",
markers = interactive() && requireNamespace("rstudioapi", quietly = TRUE),
fixed = FALSE,
case_sensitive = FALSE,
path_pattern = getOption("sifr.path_pattern"),
path_case_sensitive = FALSE,
recursive = TRUE
)
todos(
dir = ".",
markers = interactive() && requireNamespace("rstudioapi", quietly = TRUE),
fixed = FALSE,
case_sensitive = TRUE,
path_pattern = getOption("sifr.path_pattern"),
path_case_sensitive = FALSE,
recursive = TRUE,
encoding = "unknown"
)
pattern |
|
dir |
|
markers |
|
fixed |
|
case_sensitive |
|
path_pattern |
|
path_case_sensitive |
|
recursive |
|
encoding |
passed on to |
keywords |
a |
A sif_result
or sifkw_results
data.table
with the columns:
path
- path to the file,
ln
- line number,
pos
- a list column of numeric two-column matrices
indicating start
and end of each match, see stringi::stri_locate_all()
contents
- the text contents of the line
The returned object may also contain the attributes "pattern"
(for sif()
) or "keywords"
(for sifkw()
) that contain the original
search terms
https://stackoverflow.com/a/7284583/2622641
tf <- tempfile(fileext = ".csv")
write.csv(iris, tf)
x <- sif("5.5", dir = dirname(tf), markers = FALSE, path_pattern = ".*\\.csv$")
print(x)
as.data.frame(x)
attr(x, "pattern")
if (interactive() && requireNamespace("rstudioapi", quietly = TRUE)){
print(x, markers = TRUE)
}
unlink(tf) #cleanup
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.