From 78320259c7b5d2c3a19e3e018c7ff11fbe05d48a Mon Sep 17 00:00:00 2001 From: Egor Kotov Date: Mon, 16 Dec 2024 11:35:44 +0100 Subject: [PATCH] cleanup function names, arguments and docs --- NAMESPACE | 2 +- R/data.R | 4 ++-- R/{column-values.R => source-filters.R} | 4 ++-- R/sources.R | 10 ++++++---- man/mi_data.Rd | 4 ++-- man/mi_source_coverage.Rd | 4 +++- man/{mi_column_values.Rd => mi_source_filters.Rd} | 12 ++++++------ man/mi_sources.Rd | 2 +- 8 files changed, 23 insertions(+), 19 deletions(-) rename R/{column-values.R => source-filters.R} (97%) rename man/{mi_column_values.Rd => mi_source_filters.Rd} (73%) diff --git a/NAMESPACE b/NAMESPACE index 8258c48..a3f503e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,8 @@ # Generated by roxygen2: do not edit by hand -export(mi_column_values) export(mi_data) export(mi_nuts_levels) export(mi_source_coverage) +export(mi_source_filters) export(mi_sources) importFrom(rlang,.data) diff --git a/R/data.R b/R/data.R index d31c2f1..758cfcd 100644 --- a/R/data.R +++ b/R/data.R @@ -10,7 +10,7 @@ #' and the values are the selected values for those fields. Default is an empty list. #' @param y_filters (Optional) A `named list` where the names are the filter fields for the y variable #' and the values are the selected values for those fields. Default is `NULL`. -#' @param limit An `integer` specifying the maximum number of results to return. Default is 1500. +#' @param limit An `integer` specifying the maximum number of results to return. Default is 2000. #' #' @return A `tibble` with the following columns: #' @@ -58,7 +58,7 @@ mi_data <- function( level, x_filters = list(), y_filters = NULL, - limit = 1500 + limit = 2000 ) { # Validate inputs checkmate::assert_string(x_source) diff --git a/R/column-values.R b/R/source-filters.R similarity index 97% rename from R/column-values.R rename to R/source-filters.R index 18f5f2a..f2a2024 100644 --- a/R/column-values.R +++ b/R/source-filters.R @@ -15,14 +15,14 @@ #' #' @examples #' \dontrun{ -#' mi_column_values( +#' mi_source_filters( #' source_name = "DEMO_R_FIND2", #' year = 2020, #' level = "2", #' filters = list(unit = "YR") #' ) #' } -mi_column_values <- function( +mi_source_filters <- function( source_name, year, level, diff --git a/R/sources.R b/R/sources.R index 3855121..ed06ed1 100644 --- a/R/sources.R +++ b/R/sources.R @@ -2,7 +2,7 @@ #' #' @param level a `character` string specifying the NUTS level ("0", "1", "2", or "3"). You can also always check valid NUTS levels using \code{\link{mi_nuts_levels}}. #' @param year an `integer` of length 1, specifying the year. Optional. -#' @param limit an `integer` of length 1 specifying the maximum number of sources to return. Defaults to 1000. +#' @inheritParams mi_data #' #' @return a `tibble` of sources with the following columns: #' @@ -84,7 +84,7 @@ mi_sources <- function( #' Get the NUTS level and Year coverage for a specific data source. #' #' @param source_name name of the data source -#' +#' @inheritParams mi_data #' @return a `tibble` containing the following columns: #' #' * `nuts_level`: NUTS level @@ -103,7 +103,8 @@ mi_sources <- function( #' mi_source_coverage("ghs_smod") #' } mi_source_coverage <- function( - source_name + source_name, + limit = 1500 ){ checkmate::assert_string(source_name) @@ -133,7 +134,8 @@ mi_source_coverage <- function( "User-Agent" = getOption("mapineqr.user_agent") ) |> httr2::req_url_query( - `_resource` = source_name + `_resource` = source_name, + `limit` = limit ) |> httr2::req_method("GET") |> httr2::req_perform() diff --git a/man/mi_data.Rd b/man/mi_data.Rd index db3cae5..d4b5dc9 100644 --- a/man/mi_data.Rd +++ b/man/mi_data.Rd @@ -11,7 +11,7 @@ mi_data( level, x_filters = list(), y_filters = NULL, - limit = 1500 + limit = 2000 ) } \arguments{ @@ -29,7 +29,7 @@ and the values are the selected values for those fields. Default is an empty lis \item{y_filters}{(Optional) A \verb{named list} where the names are the filter fields for the y variable and the values are the selected values for those fields. Default is \code{NULL}.} -\item{limit}{An \code{integer} specifying the maximum number of results to return. Default is 1500.} +\item{limit}{An \code{integer} specifying the maximum number of results to return. Default is 2000.} } \value{ A \code{tibble} with the following columns: diff --git a/man/mi_source_coverage.Rd b/man/mi_source_coverage.Rd index f15fe29..b39f7c6 100644 --- a/man/mi_source_coverage.Rd +++ b/man/mi_source_coverage.Rd @@ -4,10 +4,12 @@ \alias{mi_source_coverage} \title{Get NUTS level and Year coverage for a specific source} \usage{ -mi_source_coverage(source_name) +mi_source_coverage(source_name, limit = 1500) } \arguments{ \item{source_name}{name of the data source} + +\item{limit}{An \code{integer} specifying the maximum number of results to return. Default is 2000.} } \value{ a \code{tibble} containing the following columns: diff --git a/man/mi_column_values.Rd b/man/mi_source_filters.Rd similarity index 73% rename from man/mi_column_values.Rd rename to man/mi_source_filters.Rd index 159421d..a34f450 100644 --- a/man/mi_column_values.Rd +++ b/man/mi_source_filters.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/column-values.R -\name{mi_column_values} -\alias{mi_column_values} +% Please edit documentation in R/source-filters.R +\name{mi_source_filters} +\alias{mi_source_filters} \title{Get column values for filtering a source} \usage{ -mi_column_values(source_name, year, level, filters = list(), limit = 40) +mi_source_filters(source_name, year, level, filters = list(), limit = 40) } \arguments{ \item{source_name}{A \code{character} string specifying the source name (f_resource).} @@ -16,7 +16,7 @@ mi_column_values(source_name, year, level, filters = list(), limit = 40) \item{filters}{A \verb{named list} where the names are the filter fields and the values are the selected values for those fields. Default is an empty list.} -\item{limit}{an \code{integer} of length 1 specifying the maximum number of sources to return. Defaults to 1000.} +\item{limit}{An \code{integer} specifying the maximum number of results to return. Default is 2000.} } \value{ A \code{tibble} with the fields, labels, and their possible values for filtering. @@ -26,7 +26,7 @@ Fetches the possible filtering values for a given source, year, and NUTS level. } \examples{ \dontrun{ -mi_column_values( +mi_source_filters( source_name = "DEMO_R_FIND2", year = 2020, level = "2", diff --git a/man/mi_sources.Rd b/man/mi_sources.Rd index d5ddbdb..e9f32fc 100644 --- a/man/mi_sources.Rd +++ b/man/mi_sources.Rd @@ -11,7 +11,7 @@ mi_sources(level, year = NULL, limit = 1000) \item{year}{an \code{integer} of length 1, specifying the year. Optional.} -\item{limit}{an \code{integer} of length 1 specifying the maximum number of sources to return. Defaults to 1000.} +\item{limit}{An \code{integer} specifying the maximum number of results to return. Default is 2000.} } \value{ a \code{tibble} of sources with the following columns: