I have a table which has a column of emails. I'd like to split it into two columns, one for the username and the other for the domain. I have tried a couple solutions, but I'm having trouble manipulating the lists.
I can use str_locate() to find the location for the @ and use that to split. I can also use str_split.
Here is the code that I used.
my_df %>% mutate(domain = str_locate(du_email, "@")[1])
The problem is that str_locate returns a list. When I do not include a slice, [1], then I get an error because it creates too many values and when I do include a slice, then all of the values get filled with the output of the first result.