Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-leasure committed Oct 23, 2023
2 parents 287cffe + df8a5e5 commit 888a84a
Show file tree
Hide file tree
Showing 14 changed files with 1,214 additions and 834 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
/dev/*

*.env
/deploy/*.tar
/deploy/*.csv
Expand Down
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: lemur
Title: Life expectancy monitor upscaled in R
Version: 0.13.1
Version: 0.14.0
Authors@R: c(
person("Marius D.", "Pascariu", role = c("aut", "cre", "cph"), email = "rpascariu@outlook.com", comment = c(ORCID = "0000-0002-2568-6489")),
person("Jose Manuel", "Aburto", role = "aut", comment = c(ORCID = "0000-0002-2926-6879")),
Expand Down Expand Up @@ -42,9 +42,8 @@ Imports:
RPostgres
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Suggests:
testthat (>= 3.0.0)
Depends:
R (>= 2.10)

4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export(prepare_data_mode_cntr)
export(prepare_data_mode_cod)
export(prepare_data_mode_sex)
export(run_app)
export(setSliderColor_)
export(tab_md)
export(ui_dashbord)
export(ui_datatab)
export(ui_tabs)
export(useShinydashboard_)
import(data.table)
import(ggplot2)
import(golem)
Expand Down Expand Up @@ -54,6 +56,8 @@ importFrom(dplyr,summarise)
importFrom(dplyr,ungroup)
importFrom(glue,glue_data)
importFrom(htmltools,HTML)
importFrom(htmltools,attachDependencies)
importFrom(htmltools,findDependencies)
importFrom(htmltools,tagAppendAttributes)
importFrom(htmltools,tagList)
importFrom(htmltools,tags)
Expand Down
170 changes: 87 additions & 83 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,83 +1,87 @@
version 0.13.0
- Include the maternal and neonatal mortality in the SDG section;

version 0.12.2
- Add the servedMode argument in the run_app() function that would allow the user
to select the datasource at the launch of the application.

version 0.10.0
- Create datatab corresponding to dashboard figures (lifetables, cod distributions and decomposition values)

version 0.9.0
- Update database by adding macro-regions

version 0.8.2
- remove home page tab

version 0.8.1
- bug fixes. Minor but important.

version 0.8.0
- rebrand the developing R package from MortalityCauses to lemur

version 0.7.0
- add data.table filtering - major update

version 0.6.0
- make the figures plotly.

version 0.5.5
- sdg mode working. Not with refrence to 2015 values, but working without errors.

version 0.5.4
- bug fixes;
- sdg mode still not working.

version 0.5.3
- update datasets processing;
- make the sdg mode functional.Now we only need to make it work correctly and
will all the inputs.

version 0.5.2
- include tooltips to save dashboard real-estate;
- now shiny app is operational except the SDG mode.

version 0.5.1
- specify glue and purrr dependencies, remove some more warnings.

version 0.5.0
- Add yearly COD data and also a SDG classification.
- Re-run the data preprocessing scripts.
- No tests have been performed on the shiny app, so probably contains fatal bugs. To be verified in the next version.

version 0.4.5
- Fix bug issues in map;

version 0.4.5
- Add dynamic map and start the SDG mode;

version 0.3.0
- Start dashboard development;

version 0.2.0
- Include the function to compute life expectancy decomposition by age and cod;

version 0.1.0
- add function to compute cause modified life tables;

version 0.0.6
- Create function for performing decomposition of age-specific mortality
contributions in life expectancy: decompose_ex_by_age().

version 0.0.5
- Add GBD life tables consistent with the COD data over the 204 regions. Also, include hierarchical maps of the data.

version 0.0.3
- Add GBD data;

version 0.0.2
- Add WPP data;

version 0.0.1
- Start with a {golem} skeleton;
- Added a `NEWS` file to track changes to the package.
version 0.14.0
- Fix bug related to lack of maternal mortality data when male population is selected;
- Fix bug in the under 5 mortality reduction method;

version 0.13.0
- Include the maternal and neonatal mortality in the SDG section;

version 0.12.2
- Add the servedMode argument in the run_app() function that would allow the user
to select the datasource at the launch of the application.

version 0.10.0
- Create datatab corresponding to dashboard figures (lifetables, cod distributions and decomposition values)

version 0.9.0
- Update database by adding macro-regions

version 0.8.2
- remove home page tab

version 0.8.1
- bug fixes. Minor but important.

version 0.8.0
- rebrand the developing R package from MortalityCauses to lemur

version 0.7.0
- add data.table filtering - major update

version 0.6.0
- make the figures plotly.

version 0.5.5
- sdg mode working. Not with refrence to 2015 values, but working without errors.

version 0.5.4
- bug fixes;
- sdg mode still not working.

version 0.5.3
- update datasets processing;
- make the sdg mode functional.Now we only need to make it work correctly and
will all the inputs.

version 0.5.2
- include tooltips to save dashboard real-estate;
- now shiny app is operational except the SDG mode.

version 0.5.1
- specify glue and purrr dependencies, remove some more warnings.

version 0.5.0
- Add yearly COD data and also a SDG classification.
- Re-run the data preprocessing scripts.
- No tests have been performed on the shiny app, so probably contains fatal bugs. To be verified in the next version.

version 0.4.5
- Fix bug issues in map;

version 0.4.5
- Add dynamic map and start the SDG mode;

version 0.3.0
- Start dashboard development;

version 0.2.0
- Include the function to compute life expectancy decomposition by age and cod;

version 0.1.0
- add function to compute cause modified life tables;

version 0.0.6
- Create function for performing decomposition of age-specific mortality
contributions in life expectancy: decompose_ex_by_age().

version 0.0.5
- Add GBD life tables consistent with the COD data over the 204 regions. Also, include hierarchical maps of the data.

version 0.0.3
- Add GBD data;

version 0.0.2
- Add WPP data;

version 0.0.1
- Start with a {golem} skeleton;
- Added a `NEWS` file to track changes to the package.
31 changes: 18 additions & 13 deletions R/app_server.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# --------------------------------------------------- #
# -------------------------------------------------------------- #
# Author: Marius D. PASCARIU
# Last update: Thu Jun 02 15:45:46 2022
# --------------------------------------------------- #
# Last Update: Tue Oct 17 22:30:57 2023
# -------------------------------------------------------------- #

#' The application server-side
#'
Expand Down Expand Up @@ -48,7 +48,7 @@ app_server <- function(input, output, session) {

dataSource <- if (serverMode()) "sdg" else lemur::data_gbd2019_sdg

eval(
dt <- eval(
call(
name = queryFunction(),
data = dataSource,
Expand All @@ -58,11 +58,12 @@ app_server <- function(input, output, session) {
gender = input$sex,
year = input$time_slider
)
) %>%
) %>%
mutate(
cause_name = factor(cause_name, levels = lemur::data_app_input$cause_name_sdg))

}
dt
})

# 3) life tables data
Expand Down Expand Up @@ -96,8 +97,9 @@ app_server <- function(input, output, session) {

# Reduction matrix -----------------------------
data_cod_change <- reactive({

if (input$mode == "mode_sdg") {

M <- build_reduction_matrix(
data = data_sdg(),
select_cod = as.character(unique(data_sdg()$cause_name)),
Expand All @@ -120,28 +122,30 @@ app_server <- function(input, output, session) {
S6 = "Transport Injuries"
S7 = "Exposure to Forces of Nature"

M[ , S2a] <- input$sdg_2a
if (input$sex != 'male') {
# For now males are not exposed to maternal disorders :)
M[ , S2a] <- input$sdg_2a
}
M[ , S2b] <- input$sdg_2b
M[ , S3] <- input$sdg_3
M[ , S4] <- input$sdg_4
M[ , S5] <- input$sdg_5
M[ , S6] <- input$sdg_6
M[ , S7] <- input$sdg_7

# when under 5 mortality is reduced across all COD we have to deal with
# interactions, or successive reduction inputs. E.g. One may reduce
# neonatal mortality (50%) and under-five mortality (10%) resulting a 55%
# total reduction. This is what we try to in the next 5 lines.
# total reduction. This is what we try to do in the next 5 lines.

if (input$sdg_1 != 0) {
if (sum(M[S1, ]) != 0) {
M[S1, ] <- input$sdg_1 + M[S1, ] * abs(input$sdg_1)/100
M[S1, ] <- ((1 + input$sdg_1/100) * ((M[S1, ] + 100)/100) - 1) * 100
} else {
M[S1, ] <- input$sdg_1
}
}


} else {
M <- build_reduction_matrix(
data = data_cod(),
Expand Down Expand Up @@ -194,6 +198,7 @@ app_server <- function(input, output, session) {

# Decompose the difference in life expectancy at birth
data_decomp <- reactive({
# print(data_fig())
decompose_by_cod(
data_fig()$lt_initial,
data_fig()$lt_final,
Expand Down Expand Up @@ -528,7 +533,7 @@ dt_filter_local <- function(data, mode, region1, region2, gender, year) {
dt <- as.data.table(data)
dt <- dt[period == year]
dt <- dt[region %in% c(region1, region2)]

if (mode != "mode_sex") {
dt <- dt[sex == gender]
}
Expand Down
Loading

0 comments on commit 888a84a

Please sign in to comment.