Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
4 of 81 committers (4.9%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (19.5%) to scientific vocabulary
Keywords
r
regular-expression
strings
Keywords from Contributors
tidy-data
data-manipulation
grammar
visualisation
tidyverse
documentation-tool
ropensci
date-time
pandoc
rmarkdown
Last synced: 6 months ago
·
JSON representation
Repository
A fresh approach to string manipulation in R
Basic Info
- Host: GitHub
- Owner: tidyverse
- License: other
- Language: R
- Default Branch: main
- Homepage: https://stringr.tidyverse.org
- Size: 5.72 MB
Statistics
- Stars: 640
- Watchers: 36
- Forks: 191
- Open Issues: 12
- Releases: 9
Topics
r
regular-expression
strings
Created over 16 years ago
· Last pushed over 1 year ago
Metadata Files
Readme
Changelog
License
Code of conduct
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
library(stringr)
```
# stringr
[](https://cran.r-project.org/package=stringr)
[](https://github.com/tidyverse/stringr/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/tidyverse/stringr?branch=main)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
## Overview
Strings are not glamorous, high-profile components of R, but they do play a big role in many data cleaning and preparation tasks. The stringr package provides a cohesive set of functions designed to make working with strings as easy as possible. If you're not familiar with strings, the best place to start is the [chapter on strings](https://r4ds.hadley.nz/strings) in R for Data Science.
stringr is built on top of [stringi](https://github.com/gagolews/stringi), which uses the [ICU](https://icu.unicode.org) C library to provide fast, correct implementations of common string manipulations. stringr focusses on the most important and commonly used string manipulation functions whereas stringi provides a comprehensive set covering almost anything you can imagine. If you find that stringr is missing a function that you need, try looking in stringi. Both packages share similar conventions, so once you've mastered stringr, you should find stringi similarly easy to use.
## Installation
```r
# The easiest way to get stringr is to install the whole tidyverse:
install.packages("tidyverse")
# Alternatively, install just stringr:
install.packages("stringr")
```
## Cheatsheet
## Usage
All functions in stringr start with `str_` and take a vector of strings as the first argument:
```{r}
x <- c("why", "video", "cross", "extra", "deal", "authority")
str_length(x)
str_c(x, collapse = ", ")
str_sub(x, 1, 2)
```
Most string functions work with regular expressions, a concise language for describing patterns of text. For example, the regular expression `"[aeiou]"` matches any single character that is a vowel:
```{r}
str_subset(x, "[aeiou]")
str_count(x, "[aeiou]")
```
There are seven main verbs that work with patterns:
* `str_detect(x, pattern)` tells you if there's any match to the pattern:
```{r}
str_detect(x, "[aeiou]")
```
* `str_count(x, pattern)` counts the number of patterns:
```{r}
str_count(x, "[aeiou]")
```
* `str_subset(x, pattern)` extracts the matching components:
```{r}
str_subset(x, "[aeiou]")
```
* `str_locate(x, pattern)` gives the position of the match:
```{r}
str_locate(x, "[aeiou]")
```
* `str_extract(x, pattern)` extracts the text of the match:
```{r}
str_extract(x, "[aeiou]")
```
* `str_match(x, pattern)` extracts parts of the match defined by parentheses:
```{r}
# extract the characters on either side of the vowel
str_match(x, "(.)[aeiou](.)")
```
* `str_replace(x, pattern, replacement)` replaces the matches with new text:
```{r}
str_replace(x, "[aeiou]", "?")
```
* `str_split(x, pattern)` splits up a string into multiple pieces:
```{r}
str_split(c("a,b", "c,d,e"), ",")
```
As well as regular expressions (the default), there are three other pattern matching engines:
* `fixed()`: match exact bytes
* `coll()`: match human letters
* `boundary()`: match boundaries
## RStudio Addin
The [RegExplain RStudio addin](https://www.garrickadenbuie.com/project/regexplain/) provides a friendly interface for working with regular expressions and functions from stringr. This addin allows you to interactively build your regexp, check the output of common string matching functions, consult the interactive help pages, or use the included resources to learn regular expressions.
This addin can easily be installed with devtools:
```r
# install.packages("devtools")
devtools::install_github("gadenbuie/regexplain")
```
## Compared to base R
R provides a solid set of string operations, but because they have grown organically over time, they can be inconsistent and a little hard to learn. Additionally, they lag behind the string operations in other programming languages, so that some things that are easy to do in languages like Ruby or Python are rather hard to do in R.
* Uses consistent function and argument names. The first argument is always
the vector of strings to modify, which makes stringr work particularly well
in conjunction with the pipe:
```{r}
letters %>%
.[1:10] %>%
str_pad(3, "right") %>%
str_c(letters[2:11])
```
* Simplifies string operations by eliminating options that you don't need
95% of the time.
* Produces outputs than can easily be used as inputs. This includes ensuring
that missing inputs result in missing outputs, and zero length inputs
result in zero length outputs.
Learn more in `vignette("from-base")`
Owner
- Name: tidyverse
- Login: tidyverse
- Kind: organization
- Website: http://tidyverse.org
- Repositories: 43
- Profile: https://github.com/tidyverse
The tidyverse is a collection of R packages that share common principles and are designed to work together seamlessly
GitHub Events
Total
- Issues event: 7
- Watch event: 34
- Issue comment event: 15
- Push event: 3
- Pull request review event: 3
- Pull request review comment event: 9
- Pull request event: 7
- Fork event: 8
Last Year
- Issues event: 7
- Watch event: 34
- Issue comment event: 15
- Push event: 3
- Pull request review event: 3
- Pull request review comment event: 9
- Pull request event: 7
- Fork event: 8
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| hadley | h****m@g****m | 494 |
| Jennifer (Jenny) Bryan | j****n@g****m | 8 |
| Mara Averick | m****k@g****m | 7 |
| gagolews | e****y@g****m | 7 |
| Stefan Milton Bache | s****n@s****k | 6 |
| Raymond Patterson | r****5@g****m | 6 |
| Chel Hee Lee | g****s@g****m | 4 |
| Hiroaki Yutani | y****i@g****m | 4 |
| edward-burn | 9****n | 4 |
| Jon Harmon | 3****k | 3 |
| Y. Yu | 5****e | 2 |
| TJ Mahr | t****r | 2 |
| Michael Chirico | c****m@g****m | 2 |
| Shian Su | r****u@g****m | 2 |
| Gábor Csárdi | c****r@g****m | 2 |
| Derek Chiu | d****u@b****a | 2 |
| Clayton Yochum | c****y@g****m | 2 |
| Christopher Gandrud | c****d@g****m | 2 |
| Salim B | g****t@s****e | 2 |
| Edgar Zamora | e****a@p****m | 1 |
| Floris Vanderhaeghe | f****e@i****e | 1 |
| Garrick Aden-Buie | g****e@m****u | 1 |
| Hugo Gruson | B****o | 1 |
| J. Allen Baron | j****d@g****m | 1 |
| Jacob Peacock | j****9@g****m | 1 |
| James Howison | j****s@h****e | 1 |
| Jesica Formoso | 3****o | 1 |
| Jim Hester | j****r@g****m | 1 |
| Chenliang Xu | l****m@g****m | 1 |
| Carl Ganz | c****z@c****u | 1 |
| and 51 more... | ||
Committer Domains (Top 20 + Academic)
google.com: 2
stefanbache.dk: 1
bccrc.ca: 1
salim.space: 1
powerschool.com: 1
inbo.be: 1
mail.usf.edu: 1
howison.name: 1
colorado.edu: 1
pirategrunt.com: 1
chl072.(none): 1
exegetic.biz: 1
berkeley.edu: 1
asu.edu: 1
vivaldi.net: 1
bio.uib.no: 1
barrows.io: 1
fishandwhistle.net: 1
europa-uni.de: 1
lincolnmullen.com: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 113
- Total pull requests: 63
- Average time to close issues: 3 months
- Average time to close pull requests: about 1 month
- Total issue authors: 80
- Total pull request authors: 29
- Average comments per issue: 1.5
- Average comments per pull request: 0.68
- Merged pull requests: 46
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 8
- Pull requests: 9
- Average time to close issues: 23 days
- Average time to close pull requests: 7 months
- Issue authors: 8
- Pull request authors: 6
- Average comments per issue: 1.0
- Average comments per pull request: 0.11
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- hadley (31)
- DanChaltiel (3)
- jzadra (2)
- Fred-Wu (1)
- davidhodge931 (1)
- Dannyzhd (1)
- mkvasnicka (1)
- leowill01 (1)
- MiguelCos (1)
- bfordAIMS (1)
- LukasWallrich (1)
- wurli (1)
- Ax3man (1)
- eauleaf (1)
- MattCowgill (1)
Pull Request Authors
- hadley (17)
- jennybc (5)
- salim-b (5)
- edward-burn (5)
- matthewjnield (2)
- krlmlr (2)
- UchidaMizuki (2)
- Rekyt (2)
- PursuitOfDataScience (2)
- VisruthSK (2)
- arnaudgallou (1)
- JBGruber (1)
- librill (1)
- kylebutts (1)
- MichaelChirico (1)
Top Labels
Issue Labels
documentation (9)
tidy-dev-day :nerd_face: (8)
feature (5)
bug (4)
upkeep (2)
reprex (1)
Pull Request Labels
breaking change :skull_and_crossbones: (2)
tidy-dev-day :nerd_face: (1)
upkeep (1)
Packages
- Total packages: 3
-
Total downloads:
- cran 978,741 last-month
- Total docker downloads: 177,795,351
-
Total dependent packages: 2,514
(may contain duplicates) -
Total dependent repositories: 12,334
(may contain duplicates) - Total versions: 33
- Total maintainers: 1
cran.r-project.org: stringr
Simple, Consistent Wrappers for Common String Operations
- Homepage: https://stringr.tidyverse.org
- Documentation: http://cran.r-project.org/web/packages/stringr/stringr.pdf
- License: MIT + file LICENSE
-
Latest release: 1.5.2
published 6 months ago
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Downloads: 0.1%
Forks count: 0.3%
Stargazers count: 0.6%
Average: 3.1%
Docker downloads count: 17.3%
Maintainers (1)
Last synced:
6 months ago
proxy.golang.org: github.com/tidyverse/stringr
- Documentation: https://pkg.go.dev/github.com/tidyverse/stringr#section-documentation
- License: other
-
Latest release: v1.5.1
published over 2 years ago
Rankings
Dependent packages count: 5.5%
Average: 5.7%
Dependent repos count: 5.9%
Last synced:
6 months ago
conda-forge.org: r-stringr
- Homepage: https://stringr.tidyverse.org
- License: MIT
-
Latest release: 1.4.1
published over 3 years ago
Rankings
Dependent packages count: 0.3%
Dependent repos count: 2.9%
Average: 8.5%
Forks count: 13.7%
Stargazers count: 17.0%
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.3 depends
- cli * imports
- ellipsis * imports
- glue >= 1.6.1 imports
- lifecycle * imports
- magrittr * imports
- rlang * imports
- stringi >= 1.5.3 imports
- vctrs * imports
- withr * imports
- covr * suggests
- htmltools * suggests
- htmlwidgets * suggests
- knitr * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/pr-fetch v2 composite
- r-lib/actions/pr-push v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite