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

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -