Skip to content

Commit

Permalink
rev -- add missing indicator target
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard-Legoupil committed Feb 14, 2024
1 parent 9e6dff4 commit a7c41db
Show file tree
Hide file tree
Showing 129 changed files with 1,258,414 additions and 355,508 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Imports:
magrittr,
scales,
showtext,
stats,
stringr,
sysfonts,
systemfonts,
Expand Down
34 changes: 24 additions & 10 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,17 @@
#' @format A data frame with 1194 rows and 8 variables:
#' \describe{
#' \item{\code{iati_identifier}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_type}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_status}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_type}}{double COLUMN_DESCRIPTION}
#' \item{\code{budget_status}}{double COLUMN_DESCRIPTION}
#' \item{\code{budget_period_start}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_period_end}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_currency}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_value_date}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_value}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_type_name}}{character COLUMN_DESCRIPTION}
#' \item{\code{budget_type_description}}{character budget_type_description}
#' \item{\code{budget_status_name}}{character budget_status_name}}
#' \item{\code{budget_status_description}}{character budget_status_description}
#'}
#' @source \url{https://iatistandard.org/en/iati-standard/203/}
#' @examples
Expand All @@ -110,17 +114,19 @@
#' @format A data frame with 26667 rows and 24 variables:
#' \describe{
#' \item{\code{iati_identifier}}{character A globally unique identifier for the activity.}
#' \item{\code{result_type}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_aggregation_status}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_type}}{double COLUMN_DESCRIPTION}
#' \item{\code{result_title}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_desc}}{logical COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_measure}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_title}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_desc}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_measure}}{double COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_aggregation_status}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_ascending}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_reference_code}}{logical COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_reference_uri}}{logical COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_reference_vocabulary}}{logical COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_baseline_location_ref}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_baseline_value}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_baseline_year}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_baseline_date}}{logical COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_baseline_location_ref}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_baseline_dimension_1}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_baseline_dimension_value_1}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_baseline_dimension_2}}{character COLUMN_DESCRIPTION}
Expand All @@ -132,9 +138,17 @@
#' \item{\code{result_indicator_target_dimension_1}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_target_value_1}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_target_dimension_2}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_target_value_2}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_target_value_2}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_actual_value}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_actual_location_ref}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_actual_dimension_1}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_actual_value_1}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_actual_dimension_2}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_indicator_actual_value_2}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_type_name}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_type_description}}{character COLUMN_DESCRIPTION}
#' \item{\code{result_type_description}}{character COLUMN_DESCRIPTION}
#' \item{\code{indicator_measure_name}}{character COLUMN_DESCRIPTION}
#' \item{\code{indicator_measure_description}}{character COLUMN_DESCRIPTION}
#'}
#' @source \url{https://iatistandard.org/en/iati-standard/203/}
#' @examples
Expand Down
10 changes: 7 additions & 3 deletions R/show_donors.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#' show_donors
#'
#' @description Who are the main donors by country in terms of number of projects and/or total budget?
#' @description Who are the main donors by country in terms of transaction?
#'
#' @param year year to select starting from 2016 - could be one year or a list
#' @param programme_lab A character vector corresponding to the name of the programme.
Expand All @@ -21,9 +21,11 @@
#' @return a graph
#' @examples
#'
#' knitr::kable( codeTransactionType |> dplyr::select(name, description) )
#' knitr::kable(iati::dataTransaction |>
#' dplyr::select( transaction_type_name, transaction_type_description) |>
#' dplyr::distinct() )
#'
#' show_donors(year = 2018,
#' show_donors(year = 2022,
#' programme_lab = "The Americas",
#' transaction_type_name = "Incoming Commitment" )
#'
Expand All @@ -47,6 +49,8 @@ show_donors <- function(year,
ctr_name = NULL,
transaction_type_name = "Incoming Commitment" ) {

## Check year is after or equal 2016


# Check if only one argument is passed
if (!is.null(programme_lab) && !is.null(iati_identifier_ops)) {
Expand Down
7 changes: 4 additions & 3 deletions R/show_indicators.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' @import dplyr
#' @import scales
#' @import unhcrthemes
#' @importFrom stats reorder
#'
#' @export
#'
Expand Down Expand Up @@ -128,15 +129,15 @@ show_indicators <- function(year,
## and now the plot
p <- ggplot2::ggplot( data = df1) +
ggplot2::coord_flip() +
# geom_col( aes(x = reorder(operation, - gap_actual_green),
# geom_col( aes(x = stats::reorder(operation, - gap_actual_green),
# y = gap_actual_green ,
# fill = gap_color_green ),
# # fill = "grey50",
# alpha = 0.3,
# width = 0.9,
# color = NA ) +
ggplot2::geom_col(
ggplot2::aes(x = reorder(operation, - gap_actual_target),
ggplot2::aes(x = stats::reorder(operation, - gap_actual_target),
y = gap_actual_target,
fill = gap_color ),
#fill = "#0072BC",
Expand All @@ -146,7 +147,7 @@ show_indicators <- function(year,
"orange" = "#FF980E",
"green" = "#069C56")) +
ggplot2::geom_text(
ggplot2::aes(x = reorder(operation, - gap_actual_target),
ggplot2::aes(x = stats::reorder(operation, - gap_actual_target),
y = gap_actual_target,
label = paste(round(gap_actual_target, 1), " %") ),
#hjust = 1.5,
Expand Down
10 changes: 8 additions & 2 deletions R/show_partnership.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#' show_partnership
#'
#' @description What’s the level of partnership between organisations when implementing projects?
#' @description How organisations partner together?
#'
#' @param year A numeric value corresponding to the year to be displayed
#' @param programme_lab A character vector corresponding to the name of the programme.
Expand Down Expand Up @@ -63,7 +63,13 @@ show_partnership <- function( year,
participating_org_type_name,
participating_org_role_name) |>
tidyr::pivot_wider(names_from = participating_org_role_name,
values_from = participating_org_eng )
values_from = participating_org_eng ,
values_fn = list) |>
dplyr::select( - Accountable) |>
dplyr::rename(Organisation =participating_org_type_name)
## replace null values...
df2[df2 == 'NULL'] <- as.list(" ")


df3 <- df |>
dplyr::select(participating_org_eng,
Expand Down
3 changes: 2 additions & 1 deletion R/show_sectors.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' @import dplyr
#' @import scales
#' @import unhcrthemes
#' @importFrom stats reorder
#'
#' @export
#' @return a graph
Expand Down Expand Up @@ -81,7 +82,7 @@ show_sectors <- function(year,


p <- ggplot2::ggplot(data = df,
ggplot2::aes(x = reorder(sector_desc, sector_pct),
ggplot2::aes(x = stats::reorder(sector_desc, sector_pct),
y = sector_pct
)) +
unhcrthemes::theme_unhcr(grid = TRUE, axis = "Y", axis_title = "Sector Percentage") +
Expand Down
Loading

0 comments on commit a7c41db

Please sign in to comment.