Skip to content

Commit

Permalink
Fixing the total # citations.
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 committed Oct 2, 2017
1 parent 8f4858a commit 7fa5036
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: gcite
Type: Package
Title: Google Citation Parser
Version: 0.8.0
Version: 0.8.1
Date: 2017-10-01
Author: John Muschelli
Maintainer: John Muschelli <muschellij2@gmail.com>
Expand Down
15 changes: 13 additions & 2 deletions R/gcite_citation_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,19 @@ gcite_citation_page.default = function(doc, title = NULL, ...) {
df = data.frame(field = fields, value = vals, stringsAsFactors = FALSE)
keep_fields = c("authors", "publication date",
"journal", "volume", "issue",
"pages", "publisher", "description")
"pages", "publisher", "description",
"total citations")
df$field = tolower(df$field)

#############################
# need different way to get total citations
#############################
cites = html_nodes(doc, xpath = '//a[@class = "gsc_oms_link"]')
cites = html_text(cites)
cites = cites[ grep("cited", tolower(cites))]
cites = trimws(sub("Cited by", "", cites))

df$value[ df$field %in% "total citations" ] = cites
df = df[ df$field %in%
keep_fields,]

Expand All @@ -95,7 +106,7 @@ gcite_citation_page.default = function(doc, title = NULL, ...) {
}
wide$title = title

citations = rvest::html_node(doc, css = "#gsc_graph_bars")
citations = rvest::html_node(doc, css = "#gsc_vcd_graph_bars")
citations = citations[!is.na(citations)]
if ( length(citations) > 0) {
citations = citations[[1]]
Expand Down

0 comments on commit 7fa5036

Please sign in to comment.