@@ -12,17 +12,17 @@ enrich_metadata_metrics <- function(metadata, metrics_sources=c("altmetric", "cr
1212 metadata <- add_altmetrics(metadata )
1313 }
1414 if (" crossref" %in% metrics_sources ) {
15- output <- add_citations(output )
15+ metadata <- add_citations(metadata )
1616 }
1717
1818 # Remove duplicate lines - TODO: check for root of this problem
19- output <- unique(output )
19+ metadata <- unique(metadata )
2020
2121 end.time <- Sys.time()
2222 time.taken <- end.time - start.time
2323 mlog $ info(paste(" vis_id:" , .GlobalEnv $ VIS_ID , " Time taken:" , time.taken , sep = " " ))
2424
25- return (output )
25+ return (metadata )
2626}
2727
2828get_altmetrics <- function (dois ) {
@@ -72,18 +72,19 @@ add_altmetrics <- function(metadata) {
7272 # merge the metadata with the results of the altmetrics
7373 # don't remove any rows from the metadata, just add the altmetrics to the
7474 # output
75- output <- merge(x = metadata , y = results , by = " doi" , all.x = TRUE , all.y = FALSE )
75+ result <- merge(x = metadata , y = results , by = " doi" , all.x = TRUE , all.y = FALSE )
7676 } else {
7777 for (metric in requested_metrics ) {
7878 metadata [[metric ]] <- NA
7979 }
8080 mlog $ info(" No altmetrics found for any paper in this dataset." )
81- output <- metadata
81+ result <- metadata
8282 }
83+ return (result )
8384}
8485
85- add_citations <- function (output ) {
86- dois <- output $ doi
86+ add_citations <- function (metadata ) {
87+ dois <- metadata $ doi
8788 valid_dois <- unique(dois [which(dois != " " )])
8889
8990 cc <- tryCatch(
@@ -96,6 +97,6 @@ add_citations <- function(output) {
9697 }
9798 )
9899 names(cc )[names(cc ) == " count" ] <- " citation_count"
99- output <- merge(x = output , y = cc , by = " doi" , all.x = TRUE )
100- return (output )
100+ result <- merge(x = metadata , y = cc , by = " doi" , all.x = TRUE )
101+ return (result )
101102}
0 commit comments