Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in grep() when using get_impactfactor #71

Open
hcacesc opened this issue Nov 15, 2018 · 8 comments
Open

error in grep() when using get_impactfactor #71

hcacesc opened this issue Nov 15, 2018 · 8 comments

Comments

@hcacesc
Copy link

hcacesc commented Nov 15, 2018

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

@jefferis
Copy link
Collaborator

jefferis commented Jul 9, 2019

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?

@JobNmadu
Copy link

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!

@jefferis
Copy link
Collaborator

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

@JobNmadu
Copy link

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)

@jefferis
Copy link
Collaborator

Please can you do

dput(PubList$Journal)

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

@JobNmadu
Copy link

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

@jefferis
Copy link
Collaborator

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)

@JobNmadu
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants