Here I have column of names where First and Last names are deliminated by space, so how can I convert it to dot deliminated? Like: Wayne.Ribbon, Rio.Mansey...
df <- data.frame (name = c("Wayne Ribbon", "Rio Mansey", "Alexandre Trakovski"),
age = c(38,54,29))
CodePudding user response:
Replace the whitespace by a period using sub
(if you always have one first name and one family name; if there are more than two parts, use gsub
):
df %>%
mutate(name = sub(" ", ".", name))
name age
1 Wayne.Ribbon 38
2 Rio.Mansey 54
3 Alexandre.Trakovski 29