dimanche 28 juin 2020

Can i use gsub function to find a pattern and replace it with 2 different patterns?

I need help with finding a pattern and replacing it by two different ways. For example, the word "Code/i" should be replaced with "Code, Codi". What code should i use in replacement to get two results separated by comma? I am new to R and assuming some metacharacters or regex needs to be used? Also, i need to use base functions and no external packages. Appreciate any feedback and help as im stuck! Thanks

a <- c("Code/i")

gsub(pattern = "/i", replacement= "", a)

Aucun commentaire:

Enregistrer un commentaire