View source: R/get_abbrtable.R
get_abbrtable | R Documentation |
This function processes a user-provided abbreviation table and optionally merges it with a system abbreviation table.
The user table can be provided as a file path, data.frame
, or data.table
.
The system table is included by default but can be excluded.
get_abbrtable(user_table = NULL, use_sys_table = TRUE)
user_table |
A user-provided abbreviation table. It can be a file path (string), a |
use_sys_table |
Logical. Whether to include the system abbreviation table ( |
The function first processes the user-provided table by checking its type:
If it's a file path, it reads the file using data.table::fread
.
If it's a data.frame
, it is converted to a data.table
.
If it's already a data.table
, no conversion is needed.
After processing the user table, the system table (abbrtable_sys
) is optionally included in the final merged table.
Duplicate entries based on journal_lower
are removed.
A data.table
containing the merged abbreviation table, with any duplicates (by journal_lower
) removed.
The resulting table contains two columns: journal_lower
and journal_abbr
.
# Example 1: Provide a user table as a CSV file path and merge with system table
user_table_path <- system.file("extdata", "myabbr.csv", package = "journalabbr", mustWork = TRUE)
abbr_table <- get_abbrtable(user_table = user_table_path, use_sys_table = TRUE)
# Example 2: Provide a user table as a data.frame
user_df <- data.frame(journal_lower = c("example journal", "sample journal"),
journal_abbr = c("EJ", "SJ"))
abbr_table <- get_abbrtable(user_table = user_df, use_sys_table = FALSE)
# Example 3: Use only the system table
abbr_table <- get_abbrtable(use_sys_table = TRUE)
abbr_table <- get_abbrtable(user_table=NULL, use_sys_table = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.