Comments (3)
I'm pretty sure the issue has to do with a dependency and/or conflict upstream. If I modify get_article_cite_history()
such that the only thing I change is to make the rvest
namespace explicit for related functions, everything works as intended.
For example, here is the original get_article_cite_history()
function:
get_article_cite_history <- function(id, article) {
{
site <- getOption("scholar_site")
id <- tidy_id(id)
url_base <- paste0(site, "/citations?", "view_op=view_citation&hl=en&citation_for_view=")
url_tail <- paste(id, article, sep = ":")
url <- paste0(url_base, url_tail)
res <- get_scholar_resp(url)
if (is.null(res))
return(NA)
httr::stop_for_status(res, "get user id / article information")
doc <- read_html(res)
years <- doc %>% html_nodes(".gsc_oci_g_t") %>% html_text() %>%
as.numeric()
vals <- doc %>% html_nodes(".gsc_oci_g_al") %>% html_text() %>%
as.numeric()
df <- data.frame(year = years, cites = vals)
if (nrow(df) > 0) {
df <- merge(data.frame(year = min(years):max(years)),
df, all.x = TRUE)
df[is.na(df)] <- 0
df$pubid <- article
}
else {
df$pubid <- vector(mode = mode(article))
}
return(df)
}
Here is my modified function (called get_article_cite_history_2()
):
get_article_cite_history_2 <- function (id, article) {
site <- getOption("scholar_site")
id <- tidy_id(id)
url_base <- paste0(site, "/citations?",
"view_op=view_citation&hl=en&citation_for_view=")
url_tail <- paste(id, article, sep=":")
url <- paste0(url_base, url_tail)
res <- get_scholar_resp(url)
httr::stop_for_status(res, "get user id / article information")
doc <- rvest::read_html(res)
## Inspect the bar chart to retrieve the citation values and years
years <- doc %>%
rvest::html_nodes(".gsc_oci_g_a") %>%
rvest::html_attr('href') %>%
stringr::str_match("as_ylo=(\\d{4})&") %>%
"["(,2) %>%
as.numeric()
vals <- doc %>%
rvest::html_nodes(".gsc_oci_g_al") %>%
rvest::html_text() %>%
as.numeric()
df <- data.frame(year = years, cites = vals)
if(nrow(df)>0) {
## There may be undefined years in the sequence so fill in these gaps
df <- merge(data.frame(year=min(years):max(years)),
df, all.x=TRUE)
df[is.na(df)] <- 0
df$pubid <- article
} else {
# complete the 0 row data.frame to be consistent with normal results
df$pubid <- vector(mode = mode(article))
}
return(df)
}
The output from running each of these:
> scholar::get_article_cite_history("eD9_J3wAAAAJ", "_FxGoFyzp5QC")
Error in data.frame(year = years, cites = vals) :
arguments imply differing number of rows: 6, 5
> get_article_cite_history_2("eD9_J3wAAAAJ", "_FxGoFyzp5QC")
year cites pubid
1 2016 3 _FxGoFyzp5QC
2 2017 1 _FxGoFyzp5QC
3 2018 0 _FxGoFyzp5QC
4 2019 1 _FxGoFyzp5QC
5 2020 1 _FxGoFyzp5QC
6 2021 5 _FxGoFyzp5QC
A suboptimal workaround right now is to simply replace the get_article_cite_history()
function with the one I made above after calling in library(scholar)
but this seems like something a dev can patch quickly.
from scholar.
I am having the same issue!
get_article_cite_history("QtuhiVMAAAAJ", "IjCSPb-OGe4C")
Error in data.frame(year = years, cites = vals) :
arguments imply differing number of rows: 16, 15
Have confirmed by looking at the google scholar page that it is articles that have years with no citations that is the problem.
Thank you so much!
from scholar.
Also having the same issue ... took a while to figure it out - any year with zero citations causes get_article_cite_history to die.
from scholar.
Related Issues (20)
- get_publications() returns NA for all pubids HOT 2
- author_position() typos in calculation for `Position_Normalized`
- get_publications() `pubid` outputs all `<NA>` HOT 1
- Getting full article citation information (not only the summary)
- get_publication 404 errors HOT 1
- Get scholar does not work for ids with punctuation
- Add new function to create .bib bibliography file for later processing HOT 6
- fix to get_scholar_id HOT 1
- Fix for duplicate profiles HOT 1
- Unclear documentation for swap_initials() within the format_publications function. HOT 1
- Error in predict_h_index() HOT 1
- get_complete_authors returns NA HOT 1
- Error in predict_h_index() HOT 3
- predict.r
- get_coauthors limited to 20 coauthors HOT 1
- add function get_pubs_all_authors - submission HOT 1
- Retrieving field-of-interest/expertise labels HOT 3
- get_publications(id) is not returning pubid HOT 3
- get_article_cite_history(id, pubid) sometimes is not returning HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scholar.