grab_first_word: Grab only the first word from a string.

Description Usage Arguments Examples

View source: R/grab_first_word.R

Description

Specify the end of the word using the splitter variable.

Usage

1
grab_first_word(e, splitter = " ")

Arguments

e

A character element to split.

splitter

The character vector that delineates where the first word ends.

Examples

1
2
3
4
5
6
7
8
grab_first_word("some string but I just want the first word")

dplyr::starwars %>%
  dplyr::select(name) %>%
  dplyr::mutate(
    first_name = purrr::map_chr(name, grab_first_word),
    droid_first_name = purrr::map_chr(first_name, grab_first_word, splitter = "-")
  )

aedobbyn/dobtools documentation built on May 28, 2019, 2:33 a.m.