Giter VIP home page Giter VIP logo

nicknamer's Introduction

nicknameR

nicknameR facilitates matching common English first names to common nicknames, a frequent problem when dealing with any name merging. The primary function returns a long or wide dataframe of names and nicknames. The function also allows on the fly formatting of the names. There are 580 unique names and 671 unique nicknames in the data.

The names data come from this GitHub repository: https://github.com/onyxrev/common_nickname_csv

Installation

Install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("jmccrain/nicknameR")

Usage

The function nicknamer results in a dataframe formatted base on the parameters format, transform, reverse, and opt_function.

library(nicknameR)

# standard long dataframe
names <- nicknamer()

dplyr::glimpse(names)
#> Rows: 1,431
#> Columns: 2
#> $ name     <chr> "Aaron", "Aaron", "Aaron", "Abel", "Abel", "Abel", "Abel",...
#> $ nickname <chr> "Erin", "Ron", "Ronnie", "Ab", "Abe", "Eb", "Ebbie", "Ab",...

length(unique(names$name))
#> [1] 580
length(unique(names$nickname))
#> [1] 671

The default output is a long dataframe, with one row per name-nickname combination. In other words, both names and nicknames will be duplicated in each column, such as Alex being a nickname for Alexander or Alexandra.

Another option is to convert the output a wide format, using the format parameter. You can also transform the strings to either full uppercase or full lower case with transform.

# wide dataframe transformed to lower case
names.wide <- nicknamer(format="wide", transform = "to_lower")

head(names.wide)
#> # A tibble: 6 x 17
#> # Groups:   name [6]
#>   name  nickname_1 nickname_2 nickname_3 nickname_4 nickname_5 nickname_6
#>   <chr> <chr>      <chr>      <chr>      <chr>      <chr>      <chr>     
#> 1 aaron erin       ron        ronnie     <NA>       <NA>       <NA>      
#> 2 abel  ab         abe        eb         ebbie      <NA>       <NA>      
#> 3 abiel ab         <NA>       <NA>       <NA>       <NA>       <NA>      
#> 4 abig~ abby       gail       nabby      <NA>       <NA>       <NA>      
#> 5 abner ab         <NA>       <NA>       <NA>       <NA>       <NA>      
#> 6 abra~ ab         abe        <NA>       <NA>       <NA>       <NA>      
#> # ... with 10 more variables: nickname_7 <chr>, nickname_8 <chr>,
#> #   nickname_9 <chr>, nickname_10 <chr>, nickname_11 <chr>, nickname_12 <chr>,
#> #   nickname_13 <chr>, nickname_14 <chr>, nickname_15 <chr>, nickname_16 <chr>

If you instead want to use the nicknames as the specific rows, you can set reverse to TRUE. Now there will be one row per nickname, so the name Alex will now have one row with two full names associated with it (Alexander and Alexandra).

# wide dataframe with nickname as the row
names.wide <- nicknamer(format="wide", transform = "to_lower", reverse=T)

Finally, the opt_function parameter allows you to pass any custom function to resulting dataframe. This transforms each name and nickname column.:

# optional function applied to names:
short.names <- nicknamer(
  format="wide",
  transform = "to_lower",
  opt_function = function(x) { str_sub(x, 1, 3) }
)

nicknamer's People

Contributors

jmccrain avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.