diff --git a/NAMESPACE b/NAMESPACE index ea72a59a1710decd4aeeea4a6e6b286d5d252ba2..ed1cd39cc1115c6dc32910a92accf237da17d793 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,6 +7,7 @@ export(get_hydrometrie_sites) export(get_hydrometrie_stations) export(get_indicateurs_services_communes) export(get_indicateurs_services_indicateurs) +export(get_indicateurs_services_services) export(get_niveaux_nappes_chroniques) export(get_niveaux_nappes_chroniques_tr) export(get_niveaux_nappes_stations) diff --git a/R/get_indicateurs_services_services.R b/R/get_indicateurs_services_services.R new file mode 100644 index 0000000000000000000000000000000000000000..e1a0b1d4660220b49dcd4ec7565b95faeb45a78b --- /dev/null +++ b/R/get_indicateurs_services_services.R @@ -0,0 +1,40 @@ +#' Retrieve performance indicators from drinking water supply and sanitation services at commune level +#' +#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-indicateurs-services} +#' +#' @template param_get_common +#' +#' @return a [tibble::tibble] with one row by commune, by service and by year and the following columns: +#' +#' - "code_service": [character] identifier of the service +#' - "nom_service": [character] name of the service +#' - "code_commune_insee": [character] identifier of the commune +#' - "nom_commune": [character] name of the commune +#' - "numero_siren ": [character] SIREN identifier of the service +#' - "type_collectivite": [character] kind of collectivity +#' - "mode_gestion": [character] management mechanism of the service +#' - "annee": [integer] year of the data +#' - The following columns are the performance indicators flagged by their respective codes. The documentation of these codes can be found at this URL: \url{https://www.services.eaufrance.fr/indicateurs/indicateurs}. +#' +#' @export +#' +#' @examples +#' # Retrieve performance indicator time series of the services in Romilly-sur-Seine +#' get_indicateurs_services_services(list(code_commune = "10323")) +#' +get_indicateurs_services_services <- function(params, + cfg = config::get(file = system.file("config.yml", + package = "hubeau"))) { + + l <- doApiQuery(api = "indicateurs_services", + operation = "services", + params = params, + cfg = cfg) + + l <- lapply(l, function(x) { + x <- c(x, x$indicateurs) + x$indicateurs <- NULL + x + }) + convert_list_to_tibble(l) +} diff --git a/R/hubeau.R b/R/hubeau.R index 847f3ef8961315e15a4a019d82791990609dcb14..95685a37db3b3e30f8e9b35bc0ef84e108a19098 100644 --- a/R/hubeau.R +++ b/R/hubeau.R @@ -22,6 +22,7 @@ #' #' - [get_indicateurs_services_communes]: performance indicators by commune #' - [get_indicateurs_services_indicateurs]: performance indicators by indicator +#' - [get_indicateurs_services_services]: performance indicators by commune for each service #' #' **API "Piézométrie"** #' diff --git a/man/get_indicateurs_services_services.Rd b/man/get_indicateurs_services_services.Rd new file mode 100644 index 0000000000000000000000000000000000000000..7b98395fd42bd9161bdab5bc9027c54e8f9f2fc9 --- /dev/null +++ b/man/get_indicateurs_services_services.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_indicateurs_services_services.R +\name{get_indicateurs_services_services} +\alias{get_indicateurs_services_services} +\title{Retrieve performance indicators from drinking water supply and sanitation services at commune level} +\usage{ +get_indicateurs_services_services( + params, + cfg = config::get(file = system.file("config.yml", package = "hubeau")) +) +} +\arguments{ +\item{params}{a \link{list} the list of parameters of the queries and their values in the format \code{list(ParamName = "Param value", ...)}, use the function \link{get_available_params} for a list of the available parameters for a given operation in an API and see the API documentation for the complete list of available filter parameters} + +\item{cfg}{a \link{config} object Configuration of the communication. Use by default the internal package +configuration} +} +\value{ +a \link[tibble:tibble]{tibble::tibble} with one row by commune, by service and by year and the following columns: +\itemize{ +\item "code_service": \link{character} identifier of the service +\item "nom_service": \link{character} name of the service +\item "code_commune_insee": \link{character} identifier of the commune +\item "nom_commune": \link{character} name of the commune +\item "numero_siren ": \link{character} SIREN identifier of the service +\item "type_collectivite": \link{character} kind of collectivity +\item "mode_gestion": \link{character} management mechanism of the service +\item "annee": \link{integer} year of the data +\item The following columns are the performance indicators flagged by their respective codes. The documentation of these codes can be found at this URL: \url{https://www.services.eaufrance.fr/indicateurs/indicateurs}. +} +} +\description{ +See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-indicateurs-services} +} +\examples{ +# Retrieve performance indicator time series of the services in Romilly-sur-Seine +get_indicateurs_services_services(list(code_commune = "10323")) + +} diff --git a/man/hubeau.Rd b/man/hubeau.Rd index 7182d815476dbc71f2fc5dc730885429ad22237e..1fdd9b31fe1165c5f09fc225098bf94f6a138fe5 100644 --- a/man/hubeau.Rd +++ b/man/hubeau.Rd @@ -29,6 +29,7 @@ Available functions: \itemize{ \item \link{get_indicateurs_services_communes}: performance indicators by commune \item \link{get_indicateurs_services_indicateurs}: performance indicators by indicator +\item \link{get_indicateurs_services_services}: performance indicators by commune for each service } \strong{API "Piézométrie"}