Skip to content

Commit

Permalink
Clarify why separate_wider_* live in tidyr
Browse files Browse the repository at this point in the history
hadley committed Nov 9, 2022
1 parent 3b9d54d commit 899c1dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions regexps.qmd
Original file line number Diff line number Diff line change
@@ -247,8 +247,8 @@ These functions are naturally paired with `mutate()` when doing data cleaning.,

### Extract variables

The last function we'll discuss comes from tidyr: `separate_wider_regex()`.
It works like the `separate_wider_location()` and `separate_wider_delim()` functions that you learned about in @sec-string-columns but takes a vector of regular expressions rather than a vector of widths or a delimiter.
The last function we'll discuss uses regular expressions to extract data out of one column into one or more new columns: `separate_wider_regex()`.
It's a peer of the `separate_wider_location()` and `separate_wider_delim()` functions that you learned about in @sec-string-columns. These functions live in tidyr because the operates on (columns of) data frames, rather than individual vectors.

Let's create a simple dataset to show how it works.
Here we have some data derived from `babynames` where we have the name, gender, and age of a bunch of people in a rather weird format[^regexps-5]:

0 comments on commit 899c1dc

Please sign in to comment.