0

I have this data frame I created using mergeDbSources of Bibliometrix Package. In this dataframe there is one column named "AB_TM" created using termExtraction. The AB_TM column consist of strings of terms (a pair of two words) seperated by semicolon ; as seen in this Screenshot of AB_TM column.

I need to do biblioNetwork with the "AB_TM". But before that I need to replace terms that are actually similar. For example, replacing "FINANCIAL STATEMENTS" with "FINANCIAL STATEMENT". How can I do this?

I have tried using argument synonyms in the termExtraction, but it seems that it only worked with extraction of Keywords (as written in the documentation of bibliometrix). I have also tried working with stringi and stringr package, but have not yet succeeded on doing it. All I can do is detect the target word with str_detect but I have not yet succeeded in working with str_replace.

Below is the code that I tried.

library(stringi)
library(stringr)

dfmerge <- "dfmerge.rda"

str_detect(dfmerge$AB_TM,
           "EQUITY VALUATIONS") #this line returned properly.

str_replace_all(dfmerge$AB_TM,
         "EQUITY VALUATIONS",
         "EQUITY VALUATION") #this line did nothing to the AB_TM after I checked with detect

stri_replace_all_fixed(
  dfmerge$AB_TM,
  "EQUITY VALUATIONS",
  "EQUITY VALUATION",
  vectorize_all = TRUE
) #this line did nothing too to the AB_TM after I checked with detect

I hope I am conveying the question correctly as this is my first question ever in Stack.

  • You are not assigning the return value back `dfmerge$AB_TM <- stri_replace_all_fixed(etc)`. – Rui Barradas Mar 01 '22 at 07:45
  • 1
    Please read this post on what makes a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). – Desmond Mar 01 '22 at 08:19
  • Welcome to SO, Mudita Lau! While it seems likely that Rui's comment is the culprit, it can be difficult to find real issues when there are glaring inconsistencies in the offered code: `dfmerge <- "dfmerge.rda"` assigns a string, not the contents, so your later code should quickly error with `Error in dfmerge$AB_TM : $ operator is invalid for atomic vectors`. I second Desmond's recommendation to improve your question by making it more reproducible. – r2evans Mar 01 '22 at 10:05

0 Answers0