How to do conditional replacement in R using "like" operator equivalent in SQL/SAS -


my data.frame has more >100 observation. below snapshot of it

   variable    bloodpressure    heartrate    residual    bloodpressure1    heartrate1    residual1    bloodpressure2    heartrate2    residual2 

i want rid of numerical parts above data.frame. new output should like

         variable          bloodpressure          heartrate          residual          bloodpressure          heartrate          residual          bloodpressure          heartrate          residual 

is there anyway can use below condition in r use in sas

 if variable "%bloodpressure%" new_variable = "bloodpressure" 

or can substring character part variable , create new_variable?

if want removed digital numbers in string, try r function $ gsub $

> gsub("\\d+","","residual1") [1] "residual" 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -