% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gho.R
\name{gho_clean}
\alias{gho_clean}
\title{Tidy a GHO Data Frame}
\usage{
gho_clean(df)
}
\arguments{
\item{df}{A data frame returned by \code{\link[=gho_data]{gho_data()}}.}
}
\value{
A \link[tibble:tibble]{tibble} with 15 columns: \code{source} (always
\code{"gho"}), \code{id}, \code{indicator}, \code{location}, \code{iso3}, \code{location_name},
\code{year}, \code{value}, \code{value_num}, \code{low}, \code{high}, \code{series} (\code{NA}),
\code{dim1}, \code{dim2}, \code{dim3}. Sorted by \code{location} then \code{year}.
Empty input returns an empty tibble with the same columns and
types.
}
\description{
Selects, renames, and type-casts the most useful columns from a GHO
observation table returned by \code{\link[=gho_data]{gho_data()}}, producing a compact
tibble in the \strong{unified DSIR cleaned-indicator schema} — the same
schema produced by \code{\link[=sdg_clean]{sdg_clean()}}, so the two outputs can be combined
directly with \code{\link[=bind_indicators]{bind_indicators()}}.
}
\details{
The mapping (GHO source → unified column) is:
\itemize{
\item \code{IndicatorCode} → \code{id}
\item \code{IndicatorCode} resolved against the GHO indicator catalog →
\code{indicator} (the human-readable name; cached at session level
after the first call)
\item \code{SpatialDim}    → \code{location}; also \code{iso3} when it matches a WHO
Member State, otherwise \code{iso3 = NA}
\item \code{TimeDim}       → \code{year} (integer)
\item \code{Value}         → \code{value} (character; raw)
\item \code{NumericValue}  → \code{value_num} (numeric)
\item \code{Low}, \code{High}   → \code{low}, \code{high} (numeric)
\item \code{Dim1}, \code{Dim2}, \code{Dim3} → \code{dim1}, \code{dim2}, \code{dim3} (character)
}

The \code{series} column is always \code{NA} for GHO output (it is an SDG-only
concept). The \code{location_name} column is populated by looking up
\code{location} (an ISO3 code or a WHO region code) against the
\code{\link{who_countries}} dataset and a hardcoded set of WHO regional names;
locations that match neither (e.g. non-Member State areas) are left
as \code{NA}.

Source columns absent from \code{df} (e.g. \code{Low} / \code{High} for indicators
without confidence intervals) are filled with typed \code{NA}, so the
output always has the same 15 columns with the same column types.

The GHO data endpoint (\verb{/api/\{IndicatorCode\}}) does not return
\code{IndicatorName}; that field lives on the catalog endpoint queried by
\code{\link[=gho_indicators]{gho_indicators()}}. On the first call within an R session,
\code{gho_clean()} fetches the catalog once and caches it for the rest of
the session, so the \code{indicator} column carries the full
human-readable indicator name. If the catalog cannot be fetched
(e.g. no network), \code{\link[=gho_indicators]{gho_indicators()}} emits a warning and the
\code{indicator} column falls back to \code{NA}.
}
\examples{
\donttest{
gho_data("NCDMORT3070", spatial_type = "country") |>
  gho_clean()
}
}
\seealso{
\code{\link[=gho_data]{gho_data()}}, \code{\link[=sdg_clean]{sdg_clean()}}, \code{\link[=bind_indicators]{bind_indicators()}}.
}
