Skip to content

Commit

Permalink
add suffix to save_process_pubmed_batch
Browse files Browse the repository at this point in the history
  • Loading branch information
rempsyc committed Mar 12, 2024
1 parent 0ef9fe5 commit fc2142a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/clean_journals_continents.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ continent_order <- function(short = FALSE) {
#' @noRd
clean_journal_names <- function(journal) {
x <- gsub("&amp;", "and", journal, fixed = TRUE)
# x <- gsub(" of the United States of America", "", x, fixed = TRUE)
x <- gsub(" of the United States of America", "", x, fixed = TRUE)
x <- gsub(":.*", "", x)
x <- gsub("[(].*", "", x)
x <- tools::toTitleCase(x)
Expand All @@ -55,7 +55,7 @@ detect_missing_journals <- function(data) {
#' instead of a regular dataframe (defaults to TRUE).
#' @export
table_journal_count <- function(data, datatable = TRUE) {
x <- dplyr::count(data, data$journal, data$field, data$year_range, sort = TRUE) %>%
x <- dplyr::count(data, .data$journal, .data$field, .data$year_range, sort = TRUE) %>%
dplyr::mutate(field = stringr::str_to_title(.data$field)) %>%
as.data.frame() %>%
dplyr::rename("year range" = "year_range") %>%
Expand Down
6 changes: 4 additions & 2 deletions R/save_process_pubmed_batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @param day_low The year the data should start.
#' @param day_high The year the data should end.
#' @param data_folder Where to save the data.
#' @param suffix What suffix to add to the name file.
#' @param batch_size The download batch size.
#' @param api_key The api key for faster processing (optional).
#' @param verbose Whether to include progress messages.
Expand Down Expand Up @@ -41,6 +42,7 @@ save_process_pubmed_batch <- function(pubmed_query_string = "",
day_low = "01",
day_high = 31,
data_folder = "data",
suffix = "",
batch_size = 5000,
api_key = NULL,
verbose = TRUE) {
Expand Down Expand Up @@ -118,7 +120,7 @@ save_process_pubmed_batch <- function(pubmed_query_string = "",
# Get full name country, continent, and region
articles.df4 <- add_region(articles.df3)

saveRDS(articles.df4, paste0(data_folder, "/articles_", year_low, "_", year_high, ".rds"))
saveRDS(articles.df4, paste0(data_folder, "/articles_", year_low, "_", year_high, suffix, ".rds"))

if (verbose) {
start <- year_low
Expand All @@ -139,7 +141,7 @@ save_process_pubmed_batch <- function(pubmed_query_string = "",

success_message <- c(
"Operation successfully completed. Congratulations!", print_time(),
"File saved in", paste0(data_folder, "/articles_", start, "_", end, ".rds\n\n")
"File saved in", paste0(data_folder, "/articles_", start, "_", end, suffix, ".rds\n\n")
)

cat(success_message)
Expand Down
Binary file modified data/journal_field.rda
Binary file not shown.
3 changes: 3 additions & 0 deletions man/save_process_pubmed_batch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fc2142a

Please sign in to comment.