I would like to have a gsub expression in R to remove everything in a string that occurs after the last space. E.g. string="Da Silva UF" should return me "Da Silva". Any thoughts?
Using $ anchor:
> string = "Da Silva UF"
> gsub(" [^ ]*$", "", string)
[1] "Da Silva"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With