Created
July 5, 2016 18:00
-
-
Save sfirke/a7aeca98a271d52c740563a821dce4b4 to your computer and use it in GitHub Desktop.
separating first and last names in email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(stringr) | |
get_part_before_dot <- function(email){ | |
x <- str_split(email, "[.]") | |
lapply(x, `[[`, 1) %>% | |
unlist | |
} | |
dat <- data.frame(email = c("robert.rosen@tntp.org", "Sam.firke@tntp.org")) | |
dat <- dat %>% | |
separate(email, into = c("email", "domain"), sep = "@") %>% | |
separate( ... ON THE DOT) | |
dat %>% | |
rowwise() %>% | |
mutate(first = get_first_last_dot(email)[1], | |
last = get_first_last_dot(email)[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment