Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
separating first and last names in email
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