From fc2142a4c7dbb7c38f48263a004cf2e2bb6b51f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Th=C3=A9riault?= <13123390+rempsyc@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:31:32 +0100 Subject: [PATCH] add suffix to save_process_pubmed_batch --- R/clean_journals_continents.R | 4 ++-- R/save_process_pubmed_batch.R | 6 ++++-- data/journal_field.rda | Bin 1376 -> 1380 bytes man/save_process_pubmed_batch.Rd | 3 +++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/R/clean_journals_continents.R b/R/clean_journals_continents.R index 4b2231a..ffde6b4 100644 --- a/R/clean_journals_continents.R +++ b/R/clean_journals_continents.R @@ -32,7 +32,7 @@ continent_order <- function(short = FALSE) { #' @noRd clean_journal_names <- function(journal) { x <- gsub("&", "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) @@ -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") %>% diff --git a/R/save_process_pubmed_batch.R b/R/save_process_pubmed_batch.R index a7017a6..4c86a2e 100644 --- a/R/save_process_pubmed_batch.R +++ b/R/save_process_pubmed_batch.R @@ -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. @@ -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) { @@ -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 @@ -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) diff --git a/data/journal_field.rda b/data/journal_field.rda index 2f016c0d086c64dbe379effbedfebb3662ad50fe..74a6576c43f685dd934edb81edff1fbec9040ccd 100644 GIT binary patch literal 1380 zcmV-q1)KUpT4*^jL0KkKS#P+F;Q$0-|HS|HZ(aO<{V+fG{@}m=-{3$X0FVFy;08Z5 zL@Y1>001F~s%=d@GJ&V40iXZ?4^Yvg6GK6u000dF1wBLn8UO$Q0BFzv0000E2AXN0 z(9qDx&_pbZApdW{~TqeqlzdSZw_1)bAo?o2b> zApcmQ>V!Q8+W?N4G@Ebk`fQK$hqqk-Bf(#Mg4e0wokV7NR&2&fDIok02tD6;7Cx5w%bX zp6G%v_Megn7{v#Ze*N{Y(aT<}NM#uuzYISerOuGmomvvOkr4c#N~HuI$`C2q#@Q8P zDMg9Tnh=nRK-3=NMb*eD8mklFCn?1uD;u^ns1ileLZYf-Copg~GC=D@9wji2CxdWP za7Pt4hqyYL&<4SoSUMt&s|eV}?X65DXcwdHo$z{d5cC9w@$GnhBi40hAD z5@`yFAQ%#$Xh5iv0U%Uxbl;}UZE2Res*V#)bYm}bDPXZ{Oc#Q`5eRTG{a7QbS<7M8 z7#xKh=ckwEwek+QdAHCb0Kt`*J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nzhfq@Eg2;&VT9PMrfO}=mUh^j#7Lx)J1k(cEMQ36t3X-XaoWa1^$pfqqc$C61JR1ct!59l? zhp=m9pc{jnt_=}MQN~Ih#Hxg3VuT47)kRoAX9gvCfc8oNJheCT?YYf2XRi!S6>jBX z#iKRFHz|t&m;lTKGH?>Cl_`=+6GTHN9HxQh%pht4h05kR3+N?!uWC1jAH!n;>Q^Sh7lA+_@D!qSWfKRmG+{fY5~4CK7{WGkBEp^ ziegtqh#<3sD^LzTvdV;HkS0X2Oy(JYm|V2W8fe2vpR#9%bM^LAXU-cFu( zrvP@@h3zgHHR9$=|i~GBklXpF3d-uZhEn?N2mb^CoEqk`t?<+ibJJtc2}>H^+Z= z6O8+uUPu#-6P>B>e{V?RaQj-g-%H}OlG58MEVkQcQ>u2fdWSo#@uFcn=D2eYSpsZTV>h2O_ZIECTy9$S5v-k91W?^ ztTqgeT&J1F%GT3UO^2z<<#jsK&)4hn&vDG_Y$}!mYl0^STCg0ciHJ0w!HZrrjl561 i%2li|RUHigB>^JV?7%fl+NFp;;_gVN3K9?I8@GV?1dRaz diff --git a/man/save_process_pubmed_batch.Rd b/man/save_process_pubmed_batch.Rd index 79158c8..e407712 100644 --- a/man/save_process_pubmed_batch.Rd +++ b/man/save_process_pubmed_batch.Rd @@ -14,6 +14,7 @@ save_process_pubmed_batch( day_low = "01", day_high = 31, data_folder = "data", + suffix = "", batch_size = 5000, api_key = NULL, verbose = TRUE @@ -38,6 +39,8 @@ save_process_pubmed_batch( \item{data_folder}{Where to save the data.} +\item{suffix}{What suffix to add to the name file.} + \item{batch_size}{The download batch size.} \item{api_key}{The api key for faster processing (optional).}