Cgrep
Highlighted grep of R objects
Install / Use
/learn @coolbutuseless/CgrepREADME
<!-- README.md is generated from README.Rmd. Please edit that file -->
cgrep
<!-- badges: start -->cgrep is a package for highlighting character representations of R
objects using regular expressions.
What’s in the box:
cgrep()for working directly on character stringscgrep_character()matches against theas.character()output of the objectcgrep_deparse()matches against thedeparse1()outputcgrep_print()matches against the defaultprint()output of the objectcgrep_str()matches against thestr()representation
Installation
You can install from GitHub with:
# install.package('remotes')
remotes::install_github('coolbutuseless/cgrep')
Example: Highlight a string in a data.frame
library(cgrep)
mtcars |>
head(20) |>
cgrep_print("Merc")
<img src="man/figures/df1.png" />
Highlight a row in a data.frame which matches a word
mtcars |>
head(20) |>
cgrep_print("^.*wood.*?$", fg = 'blue', bg = 'hotpink')
<img src="man/figures/df2.png" />
Highlight text in a string
string <-
"<xml>
<this is='not'>a real XML doc</this>
<this is='not'>a real HTML doc</this>
<this is='not'>a real XML doc</this>
<this is='not'>a real XML doc</this>
</xml>"
cgrep(string, "html", ignore.case = TRUE)
<img src="man/figures/char1.png" />
Highlighting within a character vector
vals <- c('hello', 'there', '#rstats', 'on', 'mastodon')
cgrep(vals, "rstats")
<img src="man/figures/vec_print.png" />
cgrep_deparse(vals, "rstats")
<img src="man/figures/vec_deparse.png" />
Related Software
Acknowledgements
- R Core for developing and maintaining the language.
- CRAN maintainers, for patiently shepherding packages onto CRAN and maintaining the repository
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
