splitcomma: Split Comma

View source: R/splitcomma.R

splitcommaR Documentation

Split Comma

Description

This function takes a character string in the form of Last Name (Surname), First Name or Second String, First String and transposes that string to First Name Last Name (Surname) or First String Second String while removing the comma.

Usage

splitcomma(string)

Arguments

string

character vector that contains a phrase separated by a comma or not. If not, there is no change.

Value

the character vector in the form of First Name Last Name

Author(s)

Irucka Embry

Source

  1. regex - Split on first comma in string - Stack Overflow answered by flodel on Apr 25 2012. See https://stackoverflow.com/questions/10309122/split-on-first-comma-in-string.

  2. regex - r regexp - replace title and suffix in any part of string with nothing in large file (> 2 million rows) - Stack Overflow answered by Molx on Apr 16 2015. See https://stackoverflow.com/questions/29680131/r-regexp-replace-title-and-suffix-in-any-part-of-string-with-nothing-in-large.

Examples


# Example 1

install.load::load_package("iemisc", "data.table")

dtxx <- data.table(Names = c("Cooler, Wine", "Juice, Fruit", "Hard Water",
"Hot Bath", "Set, Data"))

dtxx[, Corrected_Names := splitcomma(dtxx$Names)]

dtxx



# Example 2

xtrax <- "FALSER, BRATTIE & SIMX, AGONY"

splitcomma(xtrax)




iemisc documentation built on Sept. 25, 2023, 5:09 p.m.