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

Popular posts from this blog

javascript - How to process users in one specific order using map o each function? -

javascript - Linking from page A to a specific iframe on page B -

java - Two interface have same method name with different return type -