scholar icon indicating copy to clipboard operation
scholar copied to clipboard

error in grep() when using get_impactfactor

Open hcacesc opened this issue 6 years ago • 8 comments

Hi, I have been trying to get the IF from GScholar. I get this error: Error in grep(paste0("^", journal, "$"), impactfactor$Journal[closest], : invalid regular expression, reason 'Missing ')''

Any fix? Thanks! H

hcacesc avatar Nov 15 '18 08:11 hcacesc

late response, but to investigate would need to know the full function call that you made. Perhaps it has a bracket in the journal name?

jefferis avatar Jul 09 '19 22:07 jefferis

This command get_impactfactor(journals=PubList$journal)

Gives this error message.

Error in grep(paste0("^", journal, "$"), impactfactor$Journal[closest], : invalid regular expression, reason 'Missing ')''

What could be wrong with my command please, still the same error reported in 2018!

JobNmadu avatar Aug 29 '20 15:08 JobNmadu

Dear @JobNmadu, please see my previous comment of 9 Jul 2019. What is the journal you are querying?

jefferis avatar Aug 29 '20 17:08 jefferis

Thanks for the feedback, but as you can see, there is nothing ambiguous in the command, and also, there is no bracket. You promised to investigate, that's why I made reference to the 2018 error report.

Again, the command is:

get_impactfactor(journals=PubList$journal)

JobNmadu avatar Aug 30 '20 06:08 JobNmadu

Please can you do

dput(PubList$Journal)

and report the result. Otherwise we cannot know what input value triggered the error.

jefferis avatar Aug 30 '20 07:08 jefferis

impact <- get_impactfactor(journals=PubList$journal)

error message: Error in grep(paste0("^", journal, "$"), impactfactor$Journal[closest], : invalid regular expression, reason 'Missing ')''

id <- get_publications("C1_-HgIAAAAJ&hl")

impact <- get_impactfactor(journals=id$journal, max.distance = 0.1)

error message: Error in grep(paste0("^", journal, "$"), impactfactor$Journal[closest], : invalid regular expression, reason 'Missing ')''

dput(id$Journal) NULL

JobNmadu avatar Aug 30 '20 10:08 JobNmadu

Dear @JobNmadu,

Your second example (impact <- get_impactfactor(fix_titles(journs), max.distance = 0.1)) is reproducible. The problem in that case – as suggested in my first responses – is poor handling of brackets in journal names. You can use the function below to work around this until a fix is added to the package.

Nevertheless I am afraid that you will not find the results that interesting as I don't think any of the journals in your input could be correctly matched to an impact factor.

Best wishes,

Greg Jefferis.

fix_titles <- function(x) {
    p <- gsub(".", "\\.", x, fixed = TRUE)
    p <- gsub("([^\\])\\(", "\\1\\\\(", p)
    p <- gsub("([^\\])\\[", "\\1\\\\[", p)
    p <- gsub("([^\\])\\{", "\\1\\\\{", p)
    p
}
impact <- get_impactfactor(journals=fix_titles(id$journal), max.distance = 0.1)

jefferis avatar Aug 31 '20 17:08 jefferis

Thanks for the feedback. for curiosity sake, are the errors in the journals from me or from google?

are you working on incorporating getting the list from orchid or web of science or even Mendeley or POP or zotero which seems to be more reliable than Google in this case? Since we edit entries from those databases.

JobNmadu avatar Aug 31 '20 22:08 JobNmadu