knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", cache = FALSE )
grepr aims to provide a similar functionality as the bash command grep
and display the results as RStudio source markers
You can install the developent version of grepr from GitHub with:
remotes::install_github("GregorDeCillia/grepr")
The function grepr
can be used to find matches in files based on a regular
expression.
library(grepr) grepr("message")[5:9, ]
If grepr
is called in RStudio, the results are displayed as
RStudio source markers.
Argument | Description
-------------------|------------------------------------------------------------
pattern | a character string containing a regular expression
dir | a directory from which the search is conducted. Defaults to the working directory.
ignore_dotfiles| should hidden files be ignored? Defaults to TRUE
file_pattern | a regular expression which can be used to exclude certain files from the search
grep_umlauts
is a wrapper around grepr
which looks for umlauts via the
pattern
argument. It can be used with a flag ignore_roxygen
to skip Rd
Files and roxygen comments.
Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß
grep_umlauts(file_pattern = "README\\.Rmd")
The function print_substitution_table()
can be used to suggest alternatives
print_substitution_table()
Calls to grepr::grepr()
create objects of the class grepr
. Those objects
can be used in the following ways.
rstudioapi::sourceMarkers()
knitr::kable()
as.data.frame()
converts the matches into a tidy data.frame
that contains filenames, row numbers, colum numbers and lengths of the
matches.grep_umlauts(file_pattern = "README\\.Rmd") %>% as.data.frame()
[
and ]
)
get escaped in a way that can affect the markup of knit_print.grepr()
:
https://github.com/rstudio/rmarkdown/issues/667"
) are displayed as fancy quotes (“
) in
column content
grep_package()
which respects the contents of .gitignore
and
.Rbuildignore
by defaultgsub_umlauts()
which applies the suggestions in
print_substitution_table()
automaticallyAdd the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.