gsub in R with case condition in R -
i have data : pes + pea + pwh
i want use gsub or other function in r such -- if there pea in data keep pea (and pwh should kept too) , remove pes
so ideally condition should involve pea , pes.
final output : pea + + pwh thanks!
the question easier answer if provide sample data set. assuming intention replace strings taking account capitals ignore.case = false
should enough. example:
x <- "pes + pea + pwh + pes" gsub("pes","new text",x, ignore.case = false)
would give you:
[1] "new text + pea + pwh + pes"
Comments
Post a Comment