title: How to replace specific words in a string of a character vector in R?
body: <p>I have <a href="https://drive.google.com/file/d/10GCkYmANH8qMK7YC8E1r_JyUvZruHoDc/view?usp=sharing" rel="nofollow noreferrer">this data frame</a> I created using <code>mergeDbSources</code> of <a href="https://cran.r-project.org/web/packages/bibliometrix/" rel="nofollow noreferrer">Bibliometrix</a> Package. In this dataframe there is one column named &quot;AB_TM&quot; created using <code>termExtraction</code>. The AB_TM column consist of strings of terms (a pair of two words) seperated by semicolon <code>;</code> as seen in this <a href="https://i.stack.imgur.com/b700N.png" rel="nofollow noreferrer">Screenshot of AB_TM column</a>.</p>
  <p>I need to do <code>biblioNetwork</code> with the &quot;AB_TM&quot;. But before that I need to replace terms that are actually similar. For example, replacing &quot;FINANCIAL STATEMENT<strong>S</strong>&quot; with &quot;FINANCIAL STATEMENT&quot;. How can I do this?</p>
  <p>I have tried using argument <code>synonyms</code> in the <code>termExtraction</code>, but it seems that it only worked with extraction of Keywords (as written in the <a href="https://cran.r-project.org/web/packages/bibliometrix/bibliometrix.pdf" rel="nofollow noreferrer">documentation of bibliometrix</a>). I have also tried working with <code>stringi</code> and <code>stringr</code> package, but have not yet succeeded on doing it. All I can do is detect the target word with <code>str_detect</code> but I have not yet succeeded in working with <code>str_replace</code>.</p>
  <p>Below is the code that I tried.</p>
  <pre><code>library(stringi)
  library(stringr)
  
  dfmerge &lt;- &quot;dfmerge.rda&quot;
  
  str_detect(dfmerge$AB_TM,
             &quot;EQUITY VALUATIONS&quot;) #this line returned properly.
  
  str_replace_all(dfmerge$AB_TM,
           &quot;EQUITY VALUATIONS&quot;,
           &quot;EQUITY VALUATION&quot;) #this line did nothing to the AB_TM after I checked with detect
  
  stri_replace_all_fixed(
    dfmerge$AB_TM,
    &quot;EQUITY VALUATIONS&quot;,
    &quot;EQUITY VALUATION&quot;,
    vectorize_all = TRUE
  ) #this line did nothing too to the AB_TM after I checked with detect
  </code></pre>
  <p>I hope I am conveying the question correctly as this is my first question ever in Stack.</p>