Skip to content

Commit

Permalink
changed infosheet to contributors_table everywhere, made the code eas…
Browse files Browse the repository at this point in the history
…ier to read and more lightweight, added newsmd, updated pkgdown website, tried to resolve check warnings
  • Loading branch information
marton-balazs-kovacs committed Aug 23, 2021
1 parent b6b63ee commit 7170c3f
Show file tree
Hide file tree
Showing 64 changed files with 1,308 additions and 783 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: |
install.packages("remotes")
remotes::install_deps(dependencies = TRUE)
remotes::install_dev("pkgdown")
install.packages("pkgdown")
shell: Rscript {0}

- name: Install package
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ doc
Meta
docs
docs/
/doc/
/Meta/
5 changes: 4 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ Imports:
clipr,
htmlwidgets,
googlesheets4,
markdown
markdown,
lifecycle,
rlang,
stats
RoxygenNote: 7.1.1
Suggests:
testthat,
Expand Down
14 changes: 12 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(abbreviate)
export(abbreviate_middle_names_df)
export(add_initials)
export(clean_contributors_table)
export(clean_infosheet)
export(mod_about_modal_server)
export(mod_about_modal_ui)
export(mod_credit_roles_server)
export(mod_credit_roles_ui)
export(mod_read_spreadsheet_server)
Expand All @@ -17,13 +18,17 @@ export(mod_title_page_server)
export(mod_title_page_ui)
export(mod_xml_report_server)
export(mod_xml_report_ui)
export(print_contrib_affil)
export(print_credit_roles)
export(print_funding)
export(print_roles_readable)
export(print_title_page)
export(print_xml)
export(print_yaml)
export(read_contributors_table)
export(read_infosheet)
export(run_app)
export(validate_contributors_table)
export(validate_infosheet)
import(shiny)
importFrom(config,get)
Expand All @@ -33,8 +38,13 @@ importFrom(htmltools,HTML)
importFrom(htmltools,tagAppendAttributes)
importFrom(htmltools,tagList)
importFrom(htmltools,tags)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
importFrom(rlang,.data)
importFrom(shiny,NS)
importFrom(shiny,column)
importFrom(shiny,shinyApp)
importFrom(shiny,tagList)
importFrom(stats,na.omit)
importFrom(utils,data)
importFrom(utils,globalVariables)
13 changes: 8 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# tenzing 0.2.0

## Renamed functions
* We changed the name of the input table from _infosheet_ to _contributors_table_ throughout the R package and the Shiny application. Functions containing the term _infosheet_ are now deprecated.

## New features
* New output option is added. The new option allows users to generate the funding acknowledgment section of their manuscript. For this output it is possible to use initials or full names.
* For the contributor list output option now it is possible to use initials instead of full names. Users can also choose to list the contributions according to the CRediT taxonomy after the names of the contributors.
* `tenzing` now allows users to read the infosheet directly from Google sheets by providing the share URL of the spreadsheet.
* The app allows users to review their infosheet within the app even if it does not pass the validation checks.
* There are two new columns added to the infosheet: ORCiD iD and Funding.
* The name of the CRediT taxonomy roles in the infosheet are now fixed as well their URLs directing to each role in the taxonomy's documentation.
* `tenzing` now allows users to read the contributors_table directly from Google sheets by providing the share URL of the spreadsheet.
* The app allows users to review their contributors_table within the app even if it does not pass the validation checks.
* There are two new columns added to the contributors_table template: ORCiD iD and Funding.
* The name of the CRediT taxonomy roles in the contributors_table are now fixed as well their URLs directing to each role in the taxonomy's documentation.
* The contributors_table template is now empty. However, a filled out example template is added to the package as an external datafile. See the local_use vignette on how to load this example file.
* The title page output option now allows users to add multiple first authors and prints an additional text listing the names of the shared first authors and the email address of the corresponding author.
* The app got a new, cleaner look.

## Bug fixes
* The functions that transform full names to initials are updated and now can handle most names correctly.
* The oxford comma is now added to the output options.

15 changes: 6 additions & 9 deletions R/app_server.R
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
#' @import shiny
app_server <- function(input, output,session) {
# Show about modal
mod_about_modal_server("about_modal")

# Read in the infosheet
# Read in the contributors_table
## Save the read data as a reactive object
read_out <- mod_read_spreadsheet_server("read_spreadsheet")

# Output generating button activation
## Disable button on start and add tooltip
### Buttons that need a validated infosheet
### Buttons that need a validated contributors_table
golem::invoke_js("disable", ".btn-validate")
golem::invoke_js("add_tooltip",
list(
where = ".out-btn",
message = "Please upload a valid infosheet"))
message = "Please upload a valid contributors_table"))

## Toggle logic for multiple uploads
observeEvent(read_out$uploaded(), {
if(read_out$valid_infosheet()) {
observeEvent(read_out$upload(), {
if(read_out$is_valid()) {
golem::invoke_js("reable", ".btn-validate")
golem::invoke_js("remove_tooltip", ".out-btn")
} else{
golem::invoke_js("disable", ".btn-validate")
golem::invoke_js("add_tooltip",
list(
where = ".out-btn",
message = "Please upload a valid infosheet"))
message = "Please upload a valid contributors_table"))
}
})

Expand Down
16 changes: 9 additions & 7 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ app_ui <- function() {
class = "main-steps-title-container",
h1("1.",
class = "main-steps-title-number"),
h3("Create your infosheet",
h3("Create your contibutors table",
class = "main-steps-title"),
div(
class = "help-icon-container",
title = "Copy the infosheet template in Google Drive. Go to File -> Make a copy",
title = "Copy the contributors_table template in Google Drive. Go to File -> Make a copy",
icon("far fa-question-circle", lib = "font-awesome", class = "help-icon")
)
),
Expand All @@ -38,7 +38,7 @@ app_ui <- function() {
tags$p("Duplicate and edit the ",
style = "display: inline; margin-bottom: 0;"),
tags$a(href = "https://docs.google.com/spreadsheets/d/1Gl0cwqN_nTsdFH9yhSvi9NypBfDCEhViGq4A3MnBrG8/edit?usp=sharing",
"infosheet template",
"contributors_table template",
target="_blank",
style = "display: inline; color: #ffdf57; text-decoration: underline;")
)
Expand All @@ -50,11 +50,11 @@ app_ui <- function() {
class = "main-steps-title-container",
h1("2.",
class = "main-steps-title-number"),
h3("Load your infosheet",
h3("Load your contributors_table",
class = "main-steps-title"),
div(
class = "help-icon-container",
title = "Use the share URL of the filled out infosheet and click on the upload button. OR upload your infosheet in a .csv, .tsv or .xlsx format.",
title = "Use the share URL of the filled out contributors_table and click on the upload button. OR upload your contributors_table in a .csv, .tsv or .xlsx format.",
icon("far fa-question-circle", lib = "font-awesome", class = "help-icon")
)
),
Expand All @@ -75,7 +75,7 @@ app_ui <- function() {
class = "main-steps-title"),
div(
class = "help-icon-container",
title = "You need a valid infosheet to generate the outputs. Once you have it, click on one of the output buttons to preview and download the output.",
title = "You need a valid contributors_table to generate the outputs. Once you have it, click on one of the output buttons to preview and download the output.",
icon("far fa-question-circle", lib = "font-awesome", class = "help-icon")
)
),
Expand Down Expand Up @@ -145,6 +145,8 @@ golem_add_external_resources <- function(){
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.4/prism.min.js"),
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.4/components/prism-yaml.min.js"),
tags$link(rel = "stylesheet", type = "text/css",
href = "https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.4/themes/prism.min.css")
href = "https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.4/themes/prism.min.css"),
# Google analytics
includeHTML(app_sys("app/www/google_analytics.html"))
)
}
12 changes: 6 additions & 6 deletions R/infosheet_template.R → R/contributors_table_template.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' Template infosheet
#' Template for the contributors table
#'
#' Dataset that represents the data structure that the tenzing
#' package functions require to run without error. The dataset
#' is filled with example values and based on the online spreadsheet
#' provided in the shiny app.
#'
#' @section Remark:
#' Each row contains the contributorship information for
#' one contributor. In the template there are 3 contributors
#' added as an example but there is no limit to the number
#' of contributors while using the package.
#' Each row contains the contributorship information for
#' one contributor. In the template there are 3 contributors
#' added as an example but there is no limit to the number
#' of contributors while using the package.
#'
#' @format A dataframe with 3 rows and 22 variables:
#' \describe{
Expand Down Expand Up @@ -39,4 +39,4 @@
#' \item{'Corresponding author?'}{logical, TRUE for contributor who is the corresponding author}
#'}
#'@source \url{https://docs.google.com/spreadsheets/d/1Gl0cwqN_nTsdFH9yhSvi9NypBfDCEhViGq4A3MnBrG8/edit?usp=sharing}
"infosheet_template"
"contributors_table_template"
9 changes: 0 additions & 9 deletions R/golem_utils_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,3 @@ drop_nulls <- function(x){
# typing reactiveValues is too long
rv <- shiny::reactiveValues
rvtl <- shiny::reactiveValuesToList

# The function is from the cli package: https://github.com/jonocarroll/cli/blob/2d3fbc4b41327df82df1102cdfc0a5c99822809b/R/inline.R
glue_oxford_collapse <- function(x) {
if (length(x) >= 3) {
glue::glue_collapse(x, sep = ", ", last = ", and ")
} else {
glue::glue_collapse(x, sep = ", ", last = " and ")
}
}
53 changes: 35 additions & 18 deletions R/initials.R
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
#' Add initials to the infosheet
#' Add initials to the contributors_table
#'
#' This function adds the initials to the infosheet based on the Firstname,
#' This function adds the initials to the contributors_table based on the Firstname,
#' Middle name and Surname. The function uses whitespaces and hypens to
#' detect the separate names. Also, the function is case sensitive.
#'
#' @param infosheet the imported infosheet
#' @param contributors_table the imported contributors_table
#'
#' @return The function returns the infosheet with the initials in
#' @return The function returns the contributors_table with the initials in
#' an additional column
#' @export
add_initials <- function(infosheet) {
infosheet %>%
#'
#' @importFrom rlang .data
add_initials <- function(contributors_table) {
contributors_table %>%
# If first name contains -, abbreviate both, else, abbreviate all separate names
dplyr::mutate(fir = abbreviate(Firstname, collapse = ""),
mid = abbreviate(`Middle name`, collapse = ""),
las = abbreviate(Surname, collapse = ""),
dplyr::mutate(fir = abbreviate(.data$Firstname, collapse = ""),
mid = abbreviate(.data$`Middle name`, collapse = ""),
las = abbreviate(.data$Surname, collapse = ""),
abbrev_name = stringr::str_glue("{fir}{mid}{las}", .na = "")) %>%
# Get duplicated abbreviations
dplyr::add_count(abbrev_name, name = "dup_abr") %>%
dplyr::add_count(.data$abbrev_name, name = "dup_abr") %>%
# If abbreviation has multiple instances, add full surname
dplyr::mutate(abbrev_name = dplyr::if_else(dup_abr > 1,
dplyr::mutate(abbrev_name = dplyr::if_else(.data$dup_abr > 1,
stringr::str_glue("{fir}{mid} {Surname}", .na = ""),
abbrev_name))
.data$abbrev_name))
}

#' Abbreviate middle names
#' Abbreviate names
#'
#' Abbreviates multiple words to first letters
#'
#' @param string Character. A character vector with the names
#' @param collapse Character. A string that will be used to separate names
#'
#' @return Returns a character vector with one element.
#' @export
#'
#' @examples
#' tenzing:::abbreviate("Franz Jude Wayne", collapse = "")
Expand All @@ -56,17 +59,31 @@ abbreviate <- function(string, collapse) {
res
}

abbreviate_middle_names_df <- function(infosheet) {
infosheet %>%
#' Abbreviate middle names in a dataframe
#'
#' The function calls the \code{\link{abbreviate}} function to
#' abbreviate middle names in the `Middle name` variable in a
#' dataframe if they are present. The function requires a valid
#' `contributors_table` as an input to work.
#'
#' @param contributors_table the imported contributors_table
#'
#' @return The function returns a dataframe with abbreviated middle
#' names.
#' @export
#'
#' @importFrom rlang .data
abbreviate_middle_names_df <- function(contributors_table) {
contributors_table %>%
dplyr::mutate_at(
dplyr::vars(Firstname, `Middle name`, Surname),
dplyr::vars(.data$Firstname, .data$`Middle name`, .data$Surname),
as.character) %>%
dplyr::rowwise() %>%
dplyr::mutate(
`Middle name` = dplyr::if_else(
is.na(`Middle name`),
is.na(.data$`Middle name`),
NA_character_,
abbreviate(`Middle name`, collapse = " ")
abbreviate(.data$`Middle name`, collapse = " ")
)
) %>%
dplyr::ungroup()
Expand Down
53 changes: 0 additions & 53 deletions R/mod_about_modal.R

This file was deleted.

Loading

0 comments on commit 7170c3f

Please sign in to comment.