scholar
scholar copied to clipboard
error in grep() when using get_impactfactor
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
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?
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!
Dear @JobNmadu, please see my previous comment of 9 Jul 2019. What is the journal you are querying?
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)
Please can you do
dput(PubList$Journal)
and report the result. Otherwise we cannot know what input value triggered the error.
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
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)
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.