| Title: | Tools for Working with Names | 
| Version: | 0.0.2 | 
| Description: | A system for organizing column names in data. Aimed at supporting a prefix-based and suffix-based column naming scheme. Extends 'dplyr' functionality to add ordering by function and more explicit renaming. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| LazyData: | true | 
| RoxygenNote: | 7.3.2 | 
| Suggests: | testthat (≥ 3.0.0) | 
| Config/testthat/edition: | 3 | 
| Imports: | tibble, dplyr, stringr, tidyselect, rlang, cli | 
| URL: | https://github.com/christopherkenny/name, https://christophertkenny.com/name/ | 
| BugReports: | https://github.com/christopherkenny/name/issues | 
| Depends: | R (≥ 4.1) | 
| NeedsCompilation: | no | 
| Packaged: | 2025-09-03 15:28:24 UTC; chris | 
| Author: | Christopher T. Kenny
     | 
| Maintainer: | Christopher T. Kenny <ctkenny@proton.me> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-09-03 16:20:02 UTC | 
Add Prefix
Description
Add Prefix
Usage
add_pref(x, pref)
Arguments
x | 
 character; string to change  | 
pref | 
 character; prefix to add  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
add_pref(x, 'census_')
Add Suffix
Description
Add Suffix
Usage
add_suff(x, suff)
Arguments
x | 
 character; string to change  | 
suff | 
 character; suffix to add  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
add_suff(x, '_cen')
Compare the Names of Two Objects
Description
Compare the Names of Two Objects
Usage
compare_names(x, y)
Arguments
x | 
 first object  | 
y | 
 second object  | 
Value
character vector of differences, invisibly
Examples
s <- tibble::tibble(a = 1, b = 2, d = 3)
t <- tibble::tibble(a = 1, d = 3, c = 2)
compare_names(s, t)
List Phrases
Description
List Phrases
Usage
list_phrase(tb, loc = 2)
Arguments
tb | 
 tibble; data to list prefixes in  | 
loc | 
 number of location to list. For example   | 
Value
character
Examples
tb <- tibble::tibble(pop = 10, pop_2020_est = 9, pop_white_2020 = 8, pop_black_2020 = 2)
list_phrase(tb)
List Prefixes
Description
List Prefixes
Usage
list_pref(tb)
Arguments
tb | 
 tibble; data to list prefixes in  | 
Value
character
Examples
tb <- tibble::tibble(pop = 10, pop_2020_est = 9, pop_white_2020 = 8, pop_black_2020 = 2)
list_pref(tb)
List Suffixes
Description
List Suffixes
Usage
list_suff(tb)
Arguments
tb | 
 tibble; data to list prefixes in  | 
Value
character
Examples
tb <- tibble::tibble(pop = 10, pop_2020_est = 9, pop_white_2020 = 8, pop_black_2020 = 2)
list_suff(tb)
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- tidyselect
 all_of,any_of,contains,ends_with,everything,last_col,matches,num_range,one_of,starts_with
Relocate columns
Description
Relocate columns
Usage
relocate_with(
  .data,
  .fn,
  .cols = everything(),
  .before = NULL,
  .after = NULL,
  ...
)
Arguments
.data | 
 A   | 
.fn | 
 A function to reorder   | 
.cols | 
 Columns to move  | 
.before, .after | 
 Destination of columns. If both selected, errors. If neither, moves to right of first selected column.  | 
... | 
 additional arguments to pass to   | 
Value
And object with same type as .data.
Examples
data(sd)
sd |> relocate_with(sort)
Remove Phrase
Description
Remove Phrase
Usage
rem_phrase(x, phrase)
Arguments
x | 
 character; string to change  | 
phrase | 
 character; phrase to remove  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
rem_phrase(x, '_2020')
Remove Prefix
Description
Remove Prefix
Usage
rem_pref(x, pref)
Arguments
x | 
 character; string to change  | 
pref | 
 character; prefix to remove  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
rem_pref(x, 'pop_')
Remove Suffix
Description
Remove Suffix
Usage
rem_suff(x, suff)
Arguments
x | 
 character; string to change  | 
suff | 
 character; suffix to remove  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
rem_suff(x, '_2020')
Rename with, but Loudly
Description
Rename with, but Loudly
Usage
rename_with_loud(.data, .fn, .cols = everything(), ...)
Arguments
.data | 
 A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details.  | 
.fn | 
 A function used to transform the selected   | 
.cols | 
 <  | 
... | 
 For  For   | 
Value
.data renamed
Examples
tb <- tibble::tibble(pop = 10, pop_2020_est = 9, pop_white_2020 = 8, pop_black_2020 = 2)
rename_with_loud(tb, \(x) rem_suff(x, '_2020'))
Replace Phrase
Description
Replace Phrase
Usage
repl_phrase(x, phrase, repl)
Arguments
x | 
 character; string to change  | 
phrase | 
 character; phrase to replace  | 
repl | 
 character; phrase to replace with  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
repl_phrase(x, '_2020', '_20')
Replace Prefix
Description
Replace Prefix
Usage
repl_pref(x, pref, repl)
Arguments
x | 
 character; string to change  | 
pref | 
 character; prefix to replace  | 
repl | 
 character; prefix to replace with  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
repl_pref(x, 'pop_', 'p_')
Replace Suffix
Description
Replace Suffix
Usage
repl_suff(x, suff, repl)
Arguments
x | 
 character; string to change  | 
suff | 
 character; suffix to replace  | 
repl | 
 character; suffix to replace with  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
repl_suff(x, '_2020', '_20')
South Dakota Election and Demographic Data
Description
This data set contains demographic and election information for South Dakota
Usage
data("sd")
References
Voting and Election Science Team, 2020, "2020 Precinct-Level Election Results", https://doi.org/10.7910/DVN/K7760H, Harvard Dataverse, V23
Voting and Election Science Team, 2018, "2016 Precinct-Level Election Results", https://doi.org/10.7910/DVN/NH5S2I, Harvard Dataverse, V71
Voting and Election Science Team, 2019, "2018 Precinct-Level Election Results", https://doi.org/10.7910/DVN/UBKYRU, Harvard Dataverse, V48
Kenny & McCartan (2021, Aug. 10). ALARM Project: 2020 Redistricting Data Files. Retrieved from https://github.com/alarm-redist/census-2020/
Examples
data(sd)
Sort by Phrase
Description
Sort by Phrase
Usage
sort_phrase(x, loc = 2)
Arguments
x | 
 character; strings to sort  | 
loc | 
 number of location to sort by. For example   | 
Value
character
Examples
x <- c('pop_2020_est', 'pop_white_2020', 'pop_black_2020', 'pop_white_2021')
sort_phrase(x)
Sort by Prefix
Description
Sort by Prefix
Usage
sort_pref(x)
Arguments
x | 
 character; strings to sort  | 
Value
character
Examples
x <- c('pop', 'pop_2020_est', 'pop_white_2020', 'pop_black_2020')
sort_pref(x)
Sort by Suffix
Description
Sort by Suffix
Usage
sort_suff(x)
Arguments
x | 
 character; strings to sort  | 
Value
character
Examples
x <- c('pop_2020_est', 'pop_white_2020', 'pop_black_2020', 'pop_white_2021')
sort_suff(x)