stringr/ 0000755 0001762 0000144 00000000000 14524777112 011754 5 ustar ligges users stringr/NAMESPACE 0000644 0001762 0000144 00000002764 14520174727 013203 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method("[",stringr_pattern)
S3method("[",stringr_view)
S3method(print,stringr_view)
S3method(type,character)
S3method(type,default)
S3method(type,stringr_boundary)
S3method(type,stringr_coll)
S3method(type,stringr_fixed)
S3method(type,stringr_regex)
export("%>%")
export("str_sub<-")
export(boundary)
export(coll)
export(fixed)
export(invert_match)
export(regex)
export(str_c)
export(str_conv)
export(str_count)
export(str_detect)
export(str_dup)
export(str_ends)
export(str_equal)
export(str_escape)
export(str_extract)
export(str_extract_all)
export(str_flatten)
export(str_flatten_comma)
export(str_glue)
export(str_glue_data)
export(str_interp)
export(str_length)
export(str_like)
export(str_locate)
export(str_locate_all)
export(str_match)
export(str_match_all)
export(str_order)
export(str_pad)
export(str_rank)
export(str_remove)
export(str_remove_all)
export(str_replace)
export(str_replace_all)
export(str_replace_na)
export(str_sort)
export(str_split)
export(str_split_1)
export(str_split_fixed)
export(str_split_i)
export(str_squish)
export(str_starts)
export(str_sub)
export(str_sub_all)
export(str_subset)
export(str_to_lower)
export(str_to_sentence)
export(str_to_title)
export(str_to_upper)
export(str_trim)
export(str_trunc)
export(str_unique)
export(str_view)
export(str_view_all)
export(str_which)
export(str_width)
export(str_wrap)
export(word)
import(rlang)
import(stringi)
importFrom(glue,glue)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
stringr/LICENSE 0000644 0001762 0000144 00000000055 14524700555 012756 0 ustar ligges users YEAR: 2023
COPYRIGHT HOLDER: stringr authors
stringr/README.md 0000644 0001762 0000144 00000014323 14524700555 013233 0 ustar ligges users
# 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)
#> [1] 3 5 5 5 4 9
str_c(x, collapse = ", ")
#> [1] "why, video, cross, extra, deal, authority"
str_sub(x, 1, 2)
#> [1] "wh" "vi" "cr" "ex" "de" "au"
```
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]")
#> [1] "video" "cross" "extra" "deal" "authority"
str_count(x, "[aeiou]")
#> [1] 0 3 1 2 2 4
```
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]")
#> [1] FALSE TRUE TRUE TRUE TRUE TRUE
```
- `str_count(x, pattern)` counts the number of patterns:
``` r
str_count(x, "[aeiou]")
#> [1] 0 3 1 2 2 4
```
- `str_subset(x, pattern)` extracts the matching components:
``` r
str_subset(x, "[aeiou]")
#> [1] "video" "cross" "extra" "deal" "authority"
```
- `str_locate(x, pattern)` gives the position of the match:
``` r
str_locate(x, "[aeiou]")
#> start end
#> [1,] NA NA
#> [2,] 2 2
#> [3,] 3 3
#> [4,] 1 1
#> [5,] 2 2
#> [6,] 1 1
```
- `str_extract(x, pattern)` extracts the text of the match:
``` r
str_extract(x, "[aeiou]")
#> [1] NA "i" "o" "e" "e" "a"
```
- `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](.)")
#> [,1] [,2] [,3]
#> [1,] NA NA NA
#> [2,] "vid" "v" "d"
#> [3,] "ros" "r" "s"
#> [4,] NA NA NA
#> [5,] "dea" "d" "a"
#> [6,] "aut" "a" "t"
```
- `str_replace(x, pattern, replacement)` replaces the matches with new
text:
``` r
str_replace(x, "[aeiou]", "?")
#> [1] "why" "v?deo" "cr?ss" "?xtra" "d?al" "?uthority"
```
- `str_split(x, pattern)` splits up a string into multiple pieces:
``` r
str_split(c("a,b", "c,d,e"), ",")
#> [[1]]
#> [1] "a" "b"
#>
#> [[2]]
#> [1] "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])
#> [1] "a b" "b c" "c d" "d e" "e f" "f g" "g h" "h i" "i j" "j k"
```
- 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")`
stringr/data/ 0000755 0001762 0000144 00000000000 14520174727 012664 5 ustar ligges users stringr/data/words.rda 0000644 0001762 0000144 00000006512 12743441637 014520 0 ustar ligges users BZh91AY&SY#qa fo@ @? `w
O|u]
3=L5%:vaxM CM Si 4OA *=I A
?Jl$M $SB24 iOS L#B4 J!F
vI!}ÖO]$R9i%=3S>J YQ$$O4GS˝{ˉ6n$I߮ݲV J1Klw"
[YQ; `=C,DfUedW!`OX}FQaM,2&4 Ŏpy;:]=y?n 2(MvB;zմ\X'à&jBSBAMOfckFPpO7iJ!J3p&^4,n}1RLO:V/u]hWsQFip*{E%@!yR]AnW-/EF(I*9pYI|<7#,--,qbPTDh>fa)q71!ΡS#LZ
a("x).jf䴼 (A|!zQVg5.yUVZ!H8yZk/4ÍЫkjA0`řWcbOu]=;4pFmhZzB.,yNpݸJwlx _'F3á;g9 CL":(+7:,tvɾ/ aĴ#$6T6S.ZE~{I+%㉳Qc\jqcGd$v
|&1gDfYrnUDe4U(8,MXF/ifc|Uŋ6IޜUIy^Os>˝?R>0nn\n.T.;
"ŷ5IFռ1J p_ {͢10y֊5/7
{0^nACqs4J@ >Ϥv,%uX@I Y!S$Gy|x$>vHc.PQDC%S(9BC2ȥʑqeC3t
!D".\nsxl o=4]8G}ܹfrSVM!< FRd&dM!;XrݗW>1svJ6]ޢNwPd%@fI n\1e}ge|UX*CLpAȃgFnD
\`]W0'9 }nb>tq$
8KO31p|,;=7Ú=R&[":iMÑ%yM|.-|V\5Gչ(/q#'cǜ|8s<ԡЈͬLP2GOZ'0vA}_~gCKndWS{G6]JCC;nr|"dnzW*P*>jR
Rq4
e(=C"uV9'=1܁oN"tabmlߦ`2`Hl~+ 9Pk;k7z/C܃
w*&'D0(bxT0f]}:ay<"_/7T^p#aQVH&Ѐhz;ب?)lgl&
#
T#ՒA"-.)QpC+&!mh)pX֍,ЎcÒnpڣs`k>y_!rDv3O I73ѹz4zv^fuɠ_,;E/CMQ2Hɤ y7eA3\6"HQ3c;}lW$<9,4S)!:덯5ϜWx}vL
'