Wednesday, May 29, 2019

R : remplace a String

I have a DataFrame sampleUvg50 with a column GNR in this format:

=TEXT(12040373;00000000)

And I would like to get rid of the parts "=TEXT(" and ";00000000)"

To obtain a string replacement in R, I can use the gsub function with a reg exp as follow:

sampleUvg50$GNR <- gsub(";\\d*\\)", "", gsub("=TEXT\\(", "", sampleUvg50$GNR));