This function validates the contributors_table provided to it by checking whether the provided contributors_table is compatible with the contributors_table_template(). The function early escapes only if the provided contributors_table is not a dataframe, the variable names that are present in the contributors_table_template are missing, or if the contributors_table is empty.

validate_contributors_table(contributors_table)

Arguments

contributors_table

dataframe, filled out contributors_table

Value

The function returns a list for each checked statement. Each list contains a type vector that stores whether the statement passed the check "success" or failed "warning" or "error", and a message vector that contains information about the nature of the check.

The function checks the following statements

  • error, the provided contributors_table is a dataframe

  • error, the provided contributors_table does not have the same column names as the template

  • error, the provided contributors_table is empty

  • error, Firstname variable has missing value for one of the contributors

  • error, Surname variable has a missing value for one of the contributors

  • warning, the contributors_table has duplicate names

  • warning, the contributors_table has names with duplicate initials

  • error, the 'Order in publication' variable has missing values

  • error, the 'Order in publication' variable has duplicate values

  • error, both 'Primary affiliation' and 'Secondary affiliation' variables are missing for one contributor

  • warning, there is no corresponding author added

  • warning, email address is missing for the corresponding author

  • warning, there is at least one CRediT role provided for all contributors

Examples

# Read the example contributors table file_path <- system.file("extdata", "contributors_table_example.csv", package = "tenzing", mustWork = TRUE) my_contributors_table <- read_contributors_table(contributors_table_path = file_path)
#> Rows: 5 Columns: 24
#> ── Column specification ──────────────────────────────────────────────────────── #> Delimiter: "," #> chr (7): Firstname, Middle name, Surname, Email address, Primary affiliatio... #> dbl (1): Order in publication #> lgl (16): Conceptualization, Data curation, Formal analysis, Funding acquisi...
#> #> Use `spec()` to retrieve the full column specification for this data. #> Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Validate the table check_result <- validate_contributors_table(contributors_table = my_contributors_table) # Show the results of the checks purrr::map(check_result, "type")
#> $missing_surname #> [1] "success" #> #> $missing_firstname #> [1] "success" #> #> $duplicate_names #> [1] "success" #> #> $duplicate_initials #> [1] "success" #> #> $missing_order #> [1] "success" #> #> $duplicate_order #> [1] "success" #> #> $missing_affiliation #> [1] "success" #> #> $missing_corresponding #> [1] "success" #> #> $missing_credit #> [1] "success" #> #> $missing_email #> [1] "success" #>
# Show the corresponding messages purrr::map(check_result, "message")
#> $missing_surname #> [1] "There are no missing surnames." #> #> $missing_firstname #> [1] "There are no missing firstnames." #> #> $duplicate_names #> [1] "There are no duplicate names in the contributors_table." #> #> $duplicate_initials #> [1] "There are no duplicate initials in the contributors_table." #> #> $missing_order #> [1] "There are no missing values in the order of publication." #> #> $duplicate_order #> [1] "There are no duplicated order numbers in the contributors_table." #> #> $missing_affiliation #> [1] "There are no missing affiliations in the contributors_table." #> #> $missing_corresponding #> [1] "There is at least one author indicated as corresponding author." #> #> $missing_credit #> [1] "All authors have at least one CRediT statement checked." #> #> $missing_email #> [1] "There are email addresses provided for all corresponding authors." #>