README.md

grepr

grepr aims to provide a similar functionality as the bash command grep and display the results as RStudio source markers

Installation

You can install the developent version of grepr from GitHub with:

remotes::install_github("GregorDeCillia/grepr")

Example

The function grepr can be used to find matches in files based on a regular expression.

library(grepr)
grepr("message")[5:9, ]

| file | line | content | | :--------------------- | :-------------- | :------------------------------------------------------------------------------------------ | | R/grepr.R | 60 |     message = readLines(file)[line], | | R/print.R | 5 |     rstudioapi::sourceMarkers(name = “grepr”, markup_messages(x), | | R/print.R | 9 |     message(“no matches to show”) | | R/print.R | 12 | markup_messages \<- function(matches, env_open = “\”, | | R/print.R | 20 |     message \<- match$message |

If grepr is called in RStudio, the results are displayed as RStudio source markers.

Arguments

| 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 |

Umlauts

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")

| file | line | content | | :---------------------- | :-------------- | :------------------------------------------------------ | | README.Rmd | 61 | Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß | | README.Rmd | 61 | Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß | | README.Rmd | 61 | Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß | | README.Rmd | 61 | Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß | | README.Rmd | 61 | Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß | | README.Rmd | 61 | Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß | | README.Rmd | 61 | Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß |

The function print_substitution_table() can be used to suggest alternatives

print_substitution_table()
#> the following substitutions should be used if R CMD check adds NOTEs because of umlauts
#> Ä: \u00c4    ä: \u00e4   Ö: \u00d6   ö: \u00f6   Ü: \u00dc   ü: \u00fc   ß: \u00df   

Class methods

Calls to grepr::grepr() create objects of the class grepr. Those objects can be used in the following ways.

grep_umlauts(file_pattern = "README\\.Rmd") %>% as.data.frame()
#>         file line column length                                message
#> 1 README.Rmd   61     20      1 Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß
#> 2 README.Rmd   61     23      1 Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß
#> 3 README.Rmd   61     26      1 Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß
#> 4 README.Rmd   61     29      1 Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß
#> 5 README.Rmd   61     32      1 Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß
#> 6 README.Rmd   61     35      1 Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß
#> 7 README.Rmd   61     38      1 Supported symbols: Ö, Ä, Ü, ö, ä, ü, ß

Known Issues

Possible improvements



GregorDeCillia/grepr documentation built on Oct. 30, 2019, 6:33 p.m.