Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

R: How to replace dots by dot in names?

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))

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading