Skip to content

Commit 2fe7fe3

Browse files
authored
Merge pull request #233 from ESHackathon/dev
Merge 1.1.0 updates and fixes
2 parents 6240245 + 2143779 commit 2fe7fe3

22 files changed

+2850
-644
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
^renv$
2+
^renv\.lock$
13
^.*\.Rproj$
24
^\.Rproj\.user$
35
^LICENSE\.md$

.github/workflows/document-and-deploy.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ jobs:
5353
R -e "
5454
remotes::install_github('ESHackathon/CiteSource', force = TRUE);
5555
rsconnect::setAccountInfo(name=${{secrets.SHINY_LUKAS_ACCOUNT}}, token=${{secrets.SHINY_LUKAS_TOKEN}}, secret=${{secrets.SHINY_LUKAS_SECRET}});
56-
rsconnect::deployApp(appName = 'CiteSource_latest', appDir = './inst/shiny-app/CiteSource', forceUpdate = TRUE)"
56+
rsconnect::deployApp(
57+
appName = 'CiteSource_latest',
58+
appDir = './inst/shiny-app/CiteSource',
59+
forceUpdate = TRUE)"
5760
5861
- name: Deploy stable version from main
5962
if: github.ref == 'refs/heads/main'
@@ -63,7 +66,10 @@ jobs:
6366
R -e "
6467
remotes::install_github('ESHackathon/CiteSource', force = TRUE);
6568
rsconnect::setAccountInfo(name=${{secrets.SHINY_LUKAS_ACCOUNT}}, token=${{secrets.SHINY_LUKAS_TOKEN}}, secret=${{secrets.SHINY_LUKAS_SECRET}});
66-
rsconnect::deployApp(appName = 'CiteSource', appDir = './inst/shiny-app/CiteSource', forceUpdate = TRUE)"
69+
rsconnect::deployApp(
70+
appName = 'CiteSource',
71+
appDir = './inst/shiny-app/CiteSource',
72+
forceUpdate = TRUE)"
6773
6874
- name: Create pkgdown
6975
env:

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: CiteSource
22
Title: Analyze the Utility of Information Sources and Retrieval Methodologies for Evidence Synthesis
3-
Version: 0.0.1
3+
Version: 0.1.1
44
Date: 2023-06-22
55
Authors@R: c(
66
person("Trevor", "Riley", , "trevor.riley@noaa.gov", role = c("aut", "cre"),

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@
88

99
- Integrated new dedup function into R shiny app
1010

11+
# CiteSource 0.1.1
12+
13+
- Added new functions which allow creation of tables and plots based on deduplicated (reimported) data.
14+
15+
- Updated shiny functionality, look and feel, and documentation
16+
17+
- Added new vignettes

R/dedup.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ dedup_citations_add_manual <- function(unique_citations, additional_pairs) {
9595
unique_citations$source = unique_citations$cite_source
9696
unique_citations$label = unique_citations$cite_label
9797

98-
dedup_results <- ASySD::dedup_citations_add_manual(unique_citations, additional_pairs = additional_pairs
99-
)
98+
dedup_results <- ASySD::dedup_citations_add_manual(unique_citations,
99+
additional_pairs = additional_pairs,
100+
extra_merge_fields = "cite_string")
100101

101102
dedup_results$cite_source <- dedup_results$source
102103
dedup_results$cite_label <- dedup_results$label

R/export.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export_ris <- function(citations, filename = "citations.ris", source_field = "DB
9696
string_field, "cite_string", TRUE,
9797
label_field, "cite_label", TRUE,
9898
"C1", "duplicate_id", TRUE,
99-
"C2", "record_ids", TRUE
99+
"C2", "record_ids", TRUE,
100+
"TY", "type", TRUE
100101
),
101102
synthesisr_code_lookup %>% dplyr::filter(.data$ris_synthesisr)
102103
) %>% dplyr::distinct(.data$code, .keep_all = TRUE) # Remove fields from synthesisr specification used for CiteSource metadata

R/new_count_and_table.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,19 @@ calculate_phase_records <- function(unique_citations, n_unique, db_colname) {
315315
total_distinct_records <- dplyr::n_distinct(unique_citations$duplicate_id)
316316

317317
# Split the cite_label column and count any occurrence of "screened" and "final"
318+
# Updated for edge cases where a citation is duplicated within the screened set
318319
total_screened <- unique_citations %>%
319320
tidyr::separate_rows(cite_label, sep = ",\\s*") %>%
320321
dplyr::filter(cite_label == "screened") %>%
321-
nrow()
322+
# Count the number of distinct duplicate_ids that remain
323+
dplyr::n_distinct(duplicate_id)
322324

325+
# Updated for edge cases where a citation is duplicated within the screened set (should never happen)
323326
total_final <- unique_citations %>%
324327
tidyr::separate_rows(cite_label, sep = ",\\s*") %>%
325328
dplyr::filter(cite_label == "final") %>%
326-
nrow()
329+
# Count the number of distinct duplicate_ids that remain
330+
dplyr::n_distinct(duplicate_id)
327331

328332
# Step 2: Proceed with the regular calculation for distinct records by source
329333
distinct_count <- unique_citations %>%

R/plots.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ cite_source <- cite_label <- type <- NULL
260260
#'
261261
plot_contributions <- function(data, facets = cite_source, bars = cite_label, color = type,
262262
center = FALSE, bar_order = "keep", facet_order = "keep",
263-
color_order = "keep", totals_in_legend = TRUE) {
263+
color_order = "keep", totals_in_legend = FALSE) {
264264

265265
bars <- rlang::enquo(bars)
266266
color <- rlang::enquo(color)

R/tables.R

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,32 @@
2525
record_level_table <- function(citations, include = "sources", include_empty = TRUE, return = c("tibble", "DT"), indicator_presence = NULL, indicator_absence = NULL) {
2626

2727
if (!is.data.frame(citations) || nrow(citations) == 0) stop("Citations must be a tibble and cannot have 0 entries")
28-
28+
2929
if (is.null(indicator_absence)) {
3030
indicator_absence <- switch(return[1],
31-
tibble = FALSE,
32-
DT = "&#x2717;"
31+
tibble = FALSE,
32+
DT = "&#x2717;"
3333
)
3434
}
3535
if (is.null(indicator_presence)) {
3636
indicator_presence <- switch(return[1],
37-
tibble = TRUE,
38-
DT = "&#10004;"
37+
tibble = TRUE,
38+
DT = "&#10004;"
3939
)
4040
}
4141

4242
sources <- compare_sources(citations, comp_type = include)
43-
43+
4444
if (nrow(sources) == 0) {
4545
warning("Citations provided contain no information on ", include, ". NA will be displayed, but check whether you intended to do a different comparison")
46-
sources <- tibble::tibble(duplicate_id = citations$duplicate_id)
47-
sources[[paste0(stringr::str_sub(include, 1, -2), "__NA")]] <- TRUE
46+
sources <- tibble::tibble(duplicate_id = citations$duplicate_id)
47+
sources[[paste0(stringr::str_sub(include, 1, -2), "__NA")]] <- TRUE
4848
}
4949

5050
if (!include_empty == TRUE) {
5151
citations <- citations %>% dplyr::filter(.data$duplicate_id %in% sources$duplicate_id)
5252
}
53-
53+
5454
if (! "url" %in% colnames(citations)) {
5555
citations$url <- NA_character_
5656
}
@@ -65,17 +65,17 @@ record_level_table <- function(citations, include = "sources", include_empty = T
6565
dplyr::arrange(stringr::str_extract(.data$author, "^.*?,"), .data$citation) %>%
6666
dplyr::select("duplicate_id", "citation", "reference", "html_reference") %>%
6767
dplyr::left_join(sources, by = "duplicate_id")
68-
68+
6969
indicator_presence <- as.character(indicator_presence)
7070
indicator_absence <- as.character(indicator_absence)
71-
71+
7272
to_display <- citations %>%
7373
dplyr::select(-(1:4)) %>%
7474
dplyr::mutate(dplyr::across(dplyr::everything(), ~ ifelse(.x, indicator_presence, indicator_absence))) %>%
7575
dplyr::rename_with(~ paste0(.x, " ")) # Add space to keep column names unique
76-
76+
7777
citations <- dplyr::bind_cols(citations, to_display)
78-
78+
7979
if (return[1] == "DT") {
8080
if (!rlang::is_installed("DT")) {
8181
warning('DT can only be returned when the DT package is installed. Please run install.packages("DT")')
@@ -88,7 +88,7 @@ record_level_table <- function(citations, include = "sources", include_empty = T
8888
stringr::str_remove(glue::glue("^{type}__"))
8989
list(type = type %>% stringr::str_to_title(), values = values)
9090
}) %>% purrr::transpose()
91-
91+
9292
sketch <- htmltools::tags$table(
9393
class = "display",
9494
htmltools::tags$thead(
@@ -105,24 +105,30 @@ record_level_table <- function(citations, include = "sources", include_empty = T
105105
htmltools::tags$td(colspan = 4 + length(unlist(headings$values)), htmltools::HTML("Click on the &oplus; to view the full reference"))
106106
)
107107
)
108-
108+
109109
citations %>%
110110
dplyr::select(-"duplicate_id", -"reference") %>%
111111
cbind(" " = "&oplus;", .) %>%
112112
DT::datatable(
113113
escape = FALSE,
114114
extensions = "Buttons",
115115
options = list(
116+
pageLength = 10,
117+
lengthMenu = list(c(10, 25, 50, 100, -1), c('10', '25', '50', '100', 'All')),
116118
columnDefs = list(
117119
list(visible = FALSE, targets = c(0, 3:(3 + ncol(to_display)))),
118120
list(orderable = FALSE, className = "details-control", targets = 1)
119121
),
120-
dom = "Bfrtip",
122+
dom = "lBfrtip",
121123
buttons =
122124
list("print", list(
123125
extend = "csv", filename = "CiteSource_record_summary",
124126
text = "Download csv",
125-
exportOptions = list(columns = c(0, 2:(3 + ncol(to_display))))
127+
exportOptions = list(
128+
columns = c(0, 2:(3 + ncol(to_display))),
129+
modifier = list(page = "all")
130+
)
131+
126132
))
127133
), container = sketch,
128134
callback = DT::JS("
@@ -585,8 +591,8 @@ generate_apa_reference <- function(authors, year, title, source, volume, issue,
585591
dplyr::rowwise() %>%
586592
dplyr::mutate(
587593
reference = glue::glue("
588-
{glue::glue_collapse(initialed_names, ', ', last = ' & ')} ({year}). {nNA(title, '.')} {nNA(source, pre = '<i>', '</i>')}{nNA(volume, pre = '<i>, ', '</i>')}{nNA(issue, pre = '(', ')')}. {nNA(link, pre = '<a href = \"', '\">')}{nNA(link, '</a>')}
589-
")
594+
{glue::glue_collapse(initialed_names, ', ', last = ' & ')} ({year}). {nNA(title, '.')} {nNA(source, pre = '<i>', '</i>')}{nNA(volume, pre = '<i>, ', '</i>')}{nNA(issue, pre = '(', ')')}. {nNA(link, pre = '<a href=\"', '\" target=\"_blank\" rel=\"noopener noreferrer\">')}{nNA(link, '</a>')}
595+
")
590596
) %>%
591597
dplyr::pull(.data$reference)
592598
} else {

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CiteSource was created under [the General Public License (>=v3)](https://www.gnu
2222

2323
**Shiny Web Application**
2424

25-
Whether you know R or not, we want you to be able to use CiteSource! Check out our [CiteSource Shiny App!](https://litrev.shinyapps.io/CiteSource_latest/)
25+
Whether you know R or not, we want you to be able to use CiteSource! Check out our [CiteSource Shiny App!](https://litrev.shinyapps.io/CiteSource/)
2626

2727
## Features
2828
**Customizable Metadata Tags**

0 commit comments

Comments
 (0)