diff --git a/R/mx_api.R b/R/mx_api.R index 986193d..b25a8b0 100644 --- a/R/mx_api.R +++ b/R/mx_api.R @@ -26,9 +26,11 @@ #' @export #' #' @examples -#' if(interactive()){ -#' mx_data <- mx_api_content(from_date = "2020-01-01", -#' to_date = "2020-01-07") +#' if (interactive()) { +#' mx_data <- mx_api_content( +#' from_date = "2020-01-01", +#' to_date = "2020-01-07" +#' ) #' } #' @importFrom dplyr %>% #' @importFrom rlang .data @@ -38,7 +40,6 @@ mx_api_content <- function(from_date = "2013-01-01", clean = TRUE, server = "medrxiv", include_info = FALSE) { - # Check that the user is connected to the internet internet_check() @@ -57,7 +58,7 @@ mx_api_content <- function(from_date = "2013-01-01", details <- api_to_df(details_link) count <- as.numeric(details$messages[1, 6]) - + pages <- floor(count / 100) message("Estimated total number of records as per API metadata: ", count) @@ -80,11 +81,14 @@ mx_api_content <- function(from_date = "2013-01-01", for (cursor in 0:pages) { page <- cursor * 100 - page_link <- api_link(server, - from_date, - to_date, - format(page, - scientific = FALSE)) + page_link <- api_link( + server, + from_date, + to_date, + format(page, + scientific = FALSE + ) + ) tmp <- api_to_df(page_link) @@ -99,8 +103,10 @@ mx_api_content <- function(from_date = "2013-01-01", message("Number of records retrieved from API: ", nrow(df)) if (nrow(df) != count) { - message(paste0("The estimated \"total number\" as per the metadata ", #nocov - "can sometimes be artificially inflated.")) #nocov + message(paste0( + "The estimated \"total number\" as per the metadata ", # nocov + "can sometimes be artificially inflated." + )) # nocov } if (clean == TRUE) { @@ -139,8 +145,8 @@ mx_api_content <- function(from_date = "2013-01-01", #' @export #' #' @examples -#' if(interactive()){ -#' mx_data <- mx_api_doi("10.1101/2020.02.25.20021568") +#' if (interactive()) { +#' mx_data <- mx_api_doi("10.1101/2020.02.25.20021568") #' } #' @importFrom dplyr %>% #' @importFrom rlang .data