Skip to content

Commit

Permalink
Merge pull request #40 from nealhaddaway/Make_a_package
Browse files Browse the repository at this point in the history
Make a package
  • Loading branch information
DrMattG authored Dec 19, 2024
2 parents 5f7d64e + 10e4d72 commit 836ce22
Show file tree
Hide file tree
Showing 41 changed files with 59,752 additions and 59,855 deletions.
33 changes: 17 additions & 16 deletions .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/R/decode_dois.R="F95AE8CF"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/app.R="16CC443D"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/build_ris.R="6F85CBC8"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/decode_dois.R="94F305F8"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/functions.R="0E38325C"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/google-analytics.html="FF9CB785"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/plot_health.R="B7F16593"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/repair_refs.R="3FACFBA9"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/scan_file.R="13B1F476"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/bibfix/inst/shiny-examples/bibfix/search_openAlex.R="EF8B2266"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/citationchaser private/citationchaser/inst/shiny-examples/citationchaser/app.R="03706E48"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/citationchaser private/citationchaser/inst/shiny-examples/citationchaser/functions.R="032381A8"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/citationchaser private/citationchaser/inst/shiny-examples/citationchaser/mixed_id_wrapper.R="8380540F"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/citationchasertest/inst/shiny-examples/citationchasertest/app.R="A216DC70"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/citationchasertest/inst/shiny-examples/citationchasertest/functions.R="D49257AD"
/Users/nealhaddaway/OneDrive - SEI/ESHackathon/4.Remote 2020/citationchasertest/inst/shiny-examples/citationchasertest/mixed_id_wrapper.R="F1817740"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/DESCRIPTION="6FA2B510"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/build_ris.R="EC8188C9"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/decode_dois.R="136028EC"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/dev/fill_blanks.R="0C299367"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/fill_blanks.R="1AA9D749"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/functions.R="D6783113"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/plot_health.R="24D8B67D"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/repair_refs.R="81AE1A63"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/runBibfixApp.R="D70915BB"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/scan_file.R="5A66CA1E"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/search_openAlex.R="0AA59F97"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/R/update_retractionwatch_data.R="1A74B192"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/inst/extdata/data.csv="708A568C"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/inst/shiny-examples/bibfix/app.R="CF9E49B4"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/inst/shiny-examples/bibfix/www/Factory_Scholar.ris="25D08583"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/inst/shiny-examples/bibfix/www/Forest_scholar.ris="FA10FDC7"
C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/inst/shiny-examples/bibfix/www/lookup_table.txt="6CF87D1B"
13 changes: 11 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ Description: bibfix is an R package (with future plans for a Shiny app) that
Imports:
magrittr,
utils,
tools
tools,
MESS,
data.table,
dplyr,
httr,
jsonlite,
maditr,
stringi,
tibble
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.3.2
Depends:
R (>= 2.10)
LazyData: true
35 changes: 18 additions & 17 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Generated by roxygen2: do not edit by hand

export(build_ris)
export(getLENSData)
export(get_abstract)
export(get_doi)
export(get_urls)
export(journal_abbreviation)
export(remove_abstracts)
importFrom(dplyr,coalesce)
export(crawl_url)
export(crawl_urls)
export(decode_dois)
export(get_citation)
export(get_refs)
export(reconstruct_abstract)
export(repair_refs)
export(runBibfixApp)
export(scan_file)
export(search_openAlex)
importFrom(MESS,cumsumbinning)
importFrom(data.table,data.table)
importFrom(dplyr,bind_rows)
importFrom(dplyr,group_split)
importFrom(dplyr,mutate)
importFrom(dplyr,rename)
importFrom(dplyr,select)
importFrom(expss,vlookup)
importFrom(httr,POST)
importFrom(httr,add_headers)
importFrom(httr,content)
importFrom(jsonlite,fromJSON)
importFrom(magrittr,"%>%")
importFrom(rcrossref,cr_abstract)
importFrom(rcrossref,cr_works)
importFrom(roadoi,oadoi_fetch)
importFrom(stringdist,stringdist)
importFrom(synthesisr,read_refs)
importFrom(tidyr,unite)
importFrom(maditr,vlookup)
importFrom(stringi,stri_replace_all_fixed)
importFrom(tibble,tibble)
importFrom(utils,write.table)
1 change: 0 additions & 1 deletion R/.gitignore

This file was deleted.

File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions R/decode_dois.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ decode_dois <- function(dois,
dois <- data.frame(dois)

#load lookup_table
lookup_table <- read.delim('www/lookuptable.txt',
sep = '\t',
header = TRUE,
quote = '')

# need to replace this with call from bibfix
load("C:/Users/matthew.grainger/Documents/Projects_in_development/bibfix/data/lookup_table.rda")

#replace characters using lookup table
dois <- dois %>%
dplyr::mutate(across(c(dois), ~ stringi::stri_replace_all_fixed(
Expand Down
4 changes: 2 additions & 2 deletions inst/shiny-examples/bibfix/functions.R → R/functions.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ getLENSData <- function(token, query){

#' Find citation based on identifier
#'
#' @description
#' @description Finds a citation based on e.g. DOI
#' @param article_list List of article identifiers for which the reference
#' lists will be returned. Must be a list/vector of identifiers, e.g.
#' '"10.1186/s13750-018-0126-2" "10.1002/jrsm.1378"'.
Expand All @@ -579,7 +579,7 @@ getLENSData <- function(token, query){
#' applying for scholarly API access and creating a token once approved. See
#' 'https://www.lens.org/lens/user/subscriptions#scholar' for further details.
#' @return A dataframe containing the matching citation from Lens.org.
#' @importFrom expss vlookup
#' @importFrom maditr vlookup
#' @importFrom httr content
#' @importFrom jsonlite fromJSON
#' @importFrom data.table data.table
Expand Down
66 changes: 45 additions & 21 deletions R/plot_health.R
Original file line number Diff line number Diff line change
@@ -1,41 +1,65 @@
#' Plot RIS file health
#' remotes::install_git("https://git.rud.is/hrbrmstr/ggchicklet.git")
#' health_check <- scan_file(refs)
plot_health <- function(health_check){
#' report <- scan_file(refs)
#' health_plot <- plot_health(report)
#' health_plot
plot_health <- function(health_check, session=NULL){


health_check<-health_check[-1]
reportdf <- as.data.frame(health_check)

# Select relevant fields including n_retracted
reportdf <- select(reportdf, -c('n_complete', 'n_findable_titles', 'n_total'))
names(reportdf) <- str_to_sentence(gsub('_', ' ', gsub('n_', '', names(reportdf))))
names(reportdf) <- gsub('Doi', 'DOI', names(reportdf))

# Add n_retracted to the report
reportdf <- data.frame(field = names(reportdf),
value = t(reportdf),
row.names = NULL)

# Include retracted in field levels
reportdf$field <- factor(reportdf$field,
levels = c('DOI', 'End page', 'Start page',
'Issue', 'Volume', 'Journal',
'Abstract', 'Title', 'Year',
'Author', 'Retracted'))

# Create missing data summary
reportdf$health <- 'healthy'
reportdf$field <- factor(reportdf$field, levels = c('DOI', 'End page', 'Start page', 'Issue', 'Volume', 'Journal', 'Abstract', 'Title', 'Year', 'Author'))
new <- reportdf
new$value <- health_check$n_total - reportdf$value
new$health <- 'missing'
reportdf <- rbind(reportdf, new)
reportdf$health <- factor(reportdf$health, levels = c('missing', 'healthy'))

#correct text size in ratio 14/5: https://stackoverflow.com/questions/25061822/ggplot-geom-text-font-size-control
geom.text.size <- 5
theme.size <- 20

plot <- ggplot(data=reportdf, aes(x=value, y=field, fill=health)) +
geom_bar(stat="identity", position = 'stack') +
#geom_text(aes(label=value), position = position_dodge(width=0.9), hjust=-0.5, size=geom.text.size, color='grey50') +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.title.y=element_blank(),
axis.ticks.y = element_blank(),
text = element_text(size = theme.size, color="grey50"),
axis.text = element_text(color="grey50")) +
xlim(0, 1.1*max(reportdf$value)) +
labs(x = "Health level of field") +
scale_fill_manual(values=c('grey90', '#e43235')) +
theme(legend.position = "none")
# Plot setup
geom.text.size <- 4
theme.size <- 16

return(plot)
plot <- ggplot2::ggplot(data = reportdf,
ggplot2::aes(x = value, y = field, fill = health)) +
ggplot2::geom_bar(stat = "identity", position = 'stack') +
ggplot2::theme_minimal(base_size = theme.size) +
ggplot2::theme(
axis.title.y = ggplot2::element_blank(),
axis.ticks.y = ggplot2::element_blank(),
text = ggplot2::element_text(size = theme.size, color = "grey50"),
axis.text = ggplot2::element_text(color = "grey50"),
legend.position = "none"
) +
ggplot2::xlim(0, 1.1 * max(reportdf$value)) +
ggplot2::labs(x = "Health level of field") +
ggplot2::scale_fill_manual(values = c('grey90', '#e43235'))
if (shiny::isTruthy(session)) {
# Convert to interactive plot
plot <- plotly::ggplotly(plot, tooltip = "x")
config(plot, displayModeBar = FALSE)

}else{
plot
}

return(plot)
}
Loading

0 comments on commit 836ce22

Please sign in to comment.