Skip to content

Commit

Permalink
Merge pull request #11 from bc3LC/dev
Browse files Browse the repository at this point in the history
New gcamreport structure
  • Loading branch information
klau506 authored Sep 6, 2024
2 parents 7d24ffe + a763f6b commit dc71984
Show file tree
Hide file tree
Showing 26 changed files with 1,664 additions and 219 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Package: gcamreport
Title: gcamreport
Version: 7.0.1
Version: 1.0.0
Authors@R: c(person("Clàudia", "Rodés-Bachs", email = "claudia.rodes@bc3research.org", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-6696-7685")),
person("Jon", "Sampedro", email = "jon.sampedro@bc3research.org", role = c("aut"),
comment = c(ORCID = "0000-0002-2277-1530")),
person("Russell", "Horowitz", email = "russell.horowitz@bc3research.org", role = c("aut"),
comment = c(ORCID = "0000-0002-0270-3127")),
person("Dirk-Jan", "Van de Ven", email = "dj.vandeven@bc3research.org", role = c("aut"),
comment = c(ORCID = "0000-0001-9120-564X")))
Description: R package to produce standard IPCC reports from GCAM output.
Expand Down
6 changes: 5 additions & 1 deletion R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,12 @@ generate_report <- function(db_path = NULL, db_name = NULL, prj_name, scenarios
#'
#' @param data_path Optional. Path to an RData file containing the standardized data. If provided, this file will be used to load the data into the Shiny application. You can obtain this dataset using `gcamreport::generate_report`.
#' @param data Optional. An R dataframe or list containing the standardized data. If provided, this data will be used directly in the Shiny application. You can obtain this dataset using `gcamreport::generate_report`.
#' @param GCAM_version Main GCAM compatible version: 'v7.0' (default), 'v7.1', or 'v6.0'.
#'
#' @return Launches the Shiny interactive UI. This function does not return a value but starts the Shiny application for user interaction.
#'
#' @export
launch_gcamreport_ui <- function(data_path = NULL, data = NULL) {
launch_gcamreport_ui <- function(data_path = NULL, data = NULL, GCAM_version = 'v7.0') {
# check the user input
if (is.null(data_path) && is.null(data)) {
stop("Error: Neither 'data_path' nor 'data' has been provided. Please specify at least one of these: 'data_path' to point to the location of the dataset file or 'data' to provide the dataset directly.")
Expand All @@ -863,6 +864,9 @@ launch_gcamreport_ui <- function(data_path = NULL, data = NULL) {
data <- assign("data", get(load(data_path)))
}

# make GCAM_version a global variable
GCAM_version <<- GCAM_version

# define the dataset for launching the ui
sdata <<- suppressWarnings(
data %>%
Expand Down
72 changes: 37 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[![paper](https://github.com/bc3LC/gcamreport/actions/workflows/draft-pdf.yml/badge.svg?branch=gcam-v7.0)](https://github.com/bc3LC/gcamreport/blob/gcam-v7.0/paper/paper.pdf)
[![status](https://joss.theoj.org/papers/816fd8765945cd5f6fe6d8d1fefdde19/status.svg)](https://joss.theoj.org/papers/816fd8765945cd5f6fe6d8d1fefdde19)

<br>

<!-- ------------------------>

<!-- ------------------------>
Expand All @@ -32,7 +34,10 @@

- [Getting Started](#get-started)

- [Warnings and Error Messages](#bugs)
- [Top common Warnings and Error Messages](#bugs)


<br>

<!-- ------------------------>

Expand All @@ -46,7 +51,9 @@

[Back to Contents](#contents)

`gcamreport` is a tool that generates a consistent dataset from any scenario run by the Global Change Analysis Model ([GCAM](http://www.globalchange.umd.edu/gcam/)) that meets the reporting requirements of the Integrated Assessment Modeling Consortium ([IAMC](https://www.iamconsortium.org/)). In addition, `gcamreport` includes an interactive user widget that allows users to generate and download plots live, as well as download reduced versions of the formatted dataset in spreadsheet format.
`gcamreport` is a tool designed to generate consistent datasets from any scenario run by the Global Change Analysis Model ([GCAM](http://www.globalchange.umd.edu/gcam/)), ensuring they meet the reporting standards of the Integrated Assessment Modeling Consortium ([IAMC](https://www.iamconsortium.org/)). In addition, `gcamreport` features an interactive user interface that allows users to create and download plots in real time and export reduced, formatted datasets in spreadsheet format. The tool is currently compatible with GCAM-core versions [6.0](https://zenodo.org/records/6619287), [7.0](https://zenodo.org/records/8010145), and [7.1](https://zenodo.org/records/11481167), as outlined in the [version guide](file:///C:/Users/claudia.rodes/Documents/IAM_COMPACT/gcamreport/docs/articles/Version_Guide.html).

<br>

<!-- ------------------------>

Expand Down Expand Up @@ -85,15 +92,6 @@ devtools::install_github('bc3LC/gcamreport')

Now `gcamreport` package is fully loaded. Enjoy! :smile:

**Note**:boom:: If you want to install specific `gcamreport` versions, indicate the tag or branch name when running the installation command. For instance:

``` r
# to install the tagged version "v6.0.1"
devtools::install_github('bc3LC/gcamreport@v6.0.1')

# to install the branch version "gcam-v6.0"
devtools::install_github('bc3LC/gcamreport@gcam-v6.0')
```

<br>

Expand Down Expand Up @@ -122,16 +120,6 @@ devtools::load_all()

Now `gcamreport` package is fully loaded. Enjoy! :smile:

**Note**:boom:: If you want to install specific `gcamreport` versions, indicate the tag or branch name when cloning the repository. For instance:

``` bash
# to clone the tagged version "v6.0.1":
git clone --branch v6.0.1 --single-branch https://github.com/bc3LC/gcamreport.git

# to clone the branch version "gcam-v6.0":
git clone --branch gcam-v6.0 https://github.com/bc3LC/gcamreport.git
```


<br>

Expand Down Expand Up @@ -188,15 +176,6 @@ Now `gcamreport` package is fully loaded. Enjoy! :smile:
<img src="https://raw.githubusercontent.com/bc3LC/gcamreport/gcam-v7.0/vignettes/readme_fig/shiny_error1.png" title="Click the last started docker port" alt="UI error" width="60%" height="60%"/>


**Note**:boom:: If you want to install previous `gcamreport` versions, indicate the tag or branch name when cloning the repository (step 2). For instance:

``` bash
# to clone the tagged version "v6.0.1":
git clone --branch v6.0.1 --single-branch https://github.com/bc3LC/gcamreport.git

# to clone the branch version "gcam-v6.0":
git clone --branch gcam-v6.0 https://github.com/bc3LC/gcamreport.git
```

<br>

Expand All @@ -216,7 +195,7 @@ The `gcamreport` package consists of a set of functions divided into two differe

- Dataset generation: It creates or loads an existing project and automatically saves the generated dataset that meets the reporting requirements of the [IAMC](https://www.iamconsortium.org/). Main function: `generate_report()`. For more information, see this [tutorial](https://bc3lc.github.io/gcamreport/articles/Dataset_Generation_Tutorial.html) or type `??generate_report` in your R console. If you get any warning or error messages, you might want to look at the [Warnings and Error Messages](#bugs) section.

- Interactive user block: it launches an interactive widget that displays the dataset in tabular form, with the ability to filter, reorder and download live. It also displays plots and allows them to be downloaded, aggregated by variables, regions and scenarios. Main function: `launch_gcamreport_ui()`. For more information see this [tutorial](https://bc3lc.github.io/gcamreport/articles/Interactive_UI_Tutorial.html) or type `??launch_gcamreport_ui` in your R console. If you get any warning or error messages, it might be useful to have a look at the [Warnings and Error Messages](#bugs) section.
- Interactive user block: it launches an interactive widget that displays the dataset in tabular form, with the ability to filter, reorder and download live. It also displays plots and allows them to be downloaded, aggregated by variables, regions and scenarios. Main function: `launch_gcamreport_ui()`. For more information see this [tutorial](https://bc3lc.github.io/gcamreport/articles/Interactive_UI_Tutorial.html) or type `??launch_gcamreport_ui` in your R console. If you get any warning or error messages, it might be useful to have a look at the [Top common Warnings and Error Messages](#bugs) section.


The package also includes some default input files (.Rda) that are read by the different functions. These can be changed by the user as detailed in [this tutorial](https://bc3lc.github.io/gcamreport/articles/Modify_Mapping_Template_Tutorial.html).
Expand All @@ -227,7 +206,7 @@ The package also includes some default input files (.Rda) that are read by the d

<!-- ------------------------>

## <a name="bugs"></a>Warnings and Error Messages
## <a name="bugs"></a>Top common Warnings and Error Messages

<!-- ------------------------>

Expand All @@ -237,13 +216,14 @@ The package also includes some default input files (.Rda) that are read by the d

Some typical and already-known errors that can be easily solved! :bulb:

:computer: Error on "run("path/to/your/data/myData.dat")"
:computer: Error on "generate_report(prj_name = "path/to/your/data/myData.dat")"

In your R console, you might see this error:

> generate_report("path/to/your/data/myData.dat")
[1] "Loading project..."
[1] "Loading data, performing checks, and saving output..."
Loading project...
Loading data, performing checks, and saving output...
[1] "ag_demand_clean"
Error in rgcam::getQuery(prj, "demand balances by crop commodity") :
getQuery: Query demand balances by crop commodity is not in any scenarios in the data set.
Expand Down Expand Up @@ -276,6 +256,28 @@ This problem is due to a wrong path specification. Thus, make sure that you spec

<br>

:computer: Error on "generate_report(...)"

In your R console, you might see this error:

> generate_report(...)
Loading project...
Loading data, performing checks, and saving output...
[1] "ag_demand_clean"

Error in left_join_strict(., filter_variables(get(paste("ag_demand_map", :
Error: Some rows in the left dataset do not have matching keys in the right dataset.

<details>

<summary>**Possible solution**</summary>

This problem is due to a mismatch in the `ag_demand_map` map. Thus, make sure that you specified correctly the `GCAM_verions` parameter in the `generate_report` function. If the error persists, have a look at this [tutorial](https://bc3lc.github.io/gcamreport/articles/Modify_Mapping_Template_Tutorial.html#example-1-step-by-step-to-adapt-current-mappings-to-your-GCAM-version).

</details>

<br>

:computer: Wired message when launching the UI when using the Docker installation.

After using the functions `generate_report()` or `launch_gcamreport_ui()` to launch the UI, you might get this message:
Expand Down
4 changes: 3 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ navbar:
- text: Modify Mappings and Template Tutorial
href: articles/Modify_Mapping_Template_Tutorial.html
- text: -----
- text: Documentation and tutorials for gcamreport v6.0*
- text: Depracted documentation and tutorials for gcamreport v7.0*
href: articles/gcamreport_v7-0.html
- text: Depracted documentation and tutorials for gcamreport v6.0*
href: articles/gcamreport_v6-0.html
- text: "Version Guide"
icon: fa-solid fa-seedling
Expand Down
82 changes: 0 additions & 82 deletions examples/demo.R

This file was deleted.

Binary file removed examples/example2_standardized.RData
Binary file not shown.
Binary file added examples/example2_v6.0.dat
Binary file not shown.
File renamed without changes.
Binary file added examples/example2_v7.1.dat
Binary file not shown.
Binary file added examples/example2_v7.1_standardized.RData
Binary file not shown.
31 changes: 31 additions & 0 deletions examples/example2_v7.1_standardized.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"Model","Scenario","Region","Variable","Unit","2005","2010","2015","2020","2025","2030","2035","2040","2045","2050"
"GCAM 7.1","Reference","EU-12","Agricultural Demand","million t DM/yr",194.8675436,188.9077729056,188.829033497,198.627245659,204.25751403,207.955752986,210.596100584,214.652285029,220.578827309,226.021468931
"GCAM 7.1","Reference","EU-15","Agricultural Demand","million t DM/yr",778.5559588,843.1217764,896.1859449,927.3459385,947.5355257,964.4108166,979.5296163,1010.5429101,1066.5543082,1120.686132
"GCAM 7.1","Reference","World","Agricultural Demand","million t DM/yr",973.4235024,1032.0295493056,1085.014978397,1125.973184159,1151.79303973,1172.366569586,1190.125716884,1225.195195129,1287.133135509,1346.707600931
"GCAM 7.1","Reference","EU-12","Agricultural Demand|Crops","million t DM/yr",186.1210119,175.8001610056,171.664478897,181.441641259,187.10976033,190.910042786,193.719571884,197.978467029,204.120854309,209.793290731
"GCAM 7.1","Reference","EU-15","Agricultural Demand|Crops","million t DM/yr",740.870096,782.1799386,810.7910049,840.2804285,858.9260457,874.3660966,888.1428063,917.8765101,972.7290082,1025.910612
"GCAM 7.1","Reference","World","Agricultural Demand|Crops","million t DM/yr",926.9911079,957.9800996056,982.455483797,1021.722069759,1046.03580603,1065.276139386,1081.862378184,1115.854977129,1176.849862509,1235.703902731
"GCAM 7.1","Reference","EU-12","Agricultural Demand|Crops|Energy","million t DM/yr",0.4553754,7.68468,8.20439,11.38611,11.59661,10.94375,10.61851,13.16762,18.76255,24.23309
"GCAM 7.1","Reference","EU-15","Agricultural Demand|Crops|Energy","million t DM/yr",14.96868,53.82655,55.76533,63.413,61.4444,55.71416,49.26446,62.37799,105.78372,148.1708
"GCAM 7.1","Reference","World","Agricultural Demand|Crops|Energy","million t DM/yr",15.4240554,61.51123,63.96972,74.79911,73.04101,66.65791,59.88297,75.54561,124.54627,172.40389
"GCAM 7.1","Reference","EU-12","Agricultural Demand|Crops|Feed","million t DM/yr",53.9681684,49.35493,49.4814446,53.14205683,56.70827426,59.99534316,62.66563073,64.41191158,65.36476083,66.24372933
"GCAM 7.1","Reference","EU-15","Agricultural Demand|Crops|Feed","million t DM/yr",180.37992,186.5594504,205.5625233,213.4213926,221.446377,230.5852589,239.3080324,244.7653914,245.9720382,247.8718264
"GCAM 7.1","Reference","World","Agricultural Demand|Crops|Feed","million t DM/yr",234.3480884,235.9143804,255.0439679,266.56344943,278.15465126,290.58060206,301.97366313,309.17730298,311.33679903,314.11555573
"GCAM 7.1","Reference","EU-12","Agricultural Demand|Crops|Food","million t DM/yr",79.7097638,82.4242094056,84.472489397,87.523177129,89.59528197,91.036852026,91.878933554,92.265666649,92.292849379,92.060930601
"GCAM 7.1","Reference","EU-15","Agricultural Demand|Crops|Food","million t DM/yr",332.24148,353.9580072,366.4228606,377.3616519,387.0866127,396.5005737,405.6060349,414.5697397,422.898128,430.2779866
"GCAM 7.1","Reference","World","Agricultural Demand|Crops|Food","million t DM/yr",411.9512438,436.3822166056,450.895349997,464.884829029,476.68189467,487.537425726,497.484968454,506.835406349,515.190977379,522.338917201
"GCAM 7.1","Reference","EU-12","Agricultural Demand|Crops|Other","million t DM/yr",51.9877043,36.3363416,29.5061549,29.3902973,29.2095941,28.9340976,28.5564976,28.1332688,27.7006941,27.2555408
"GCAM 7.1","Reference","EU-15","Agricultural Demand|Crops|Other","million t DM/yr",213.280016,187.835931,183.040291,186.084384,188.948656,191.566104,193.964279,196.163389,198.075122,199.589999
"GCAM 7.1","Reference","World","Agricultural Demand|Crops|Other","million t DM/yr",265.2677203,224.1722726,212.5464459,215.4746813,218.1582501,220.5002016,222.5207766,224.2966578,225.7758161,226.8455398
"GCAM 7.1","Reference","EU-12","Agricultural Demand|Livestock","million t DM/yr",8.7465317,13.1076119,17.1645546,17.1856044,17.1477537,17.0457102,16.8765287,16.673818,16.457973,16.2281782
"GCAM 7.1","Reference","EU-15","Agricultural Demand|Livestock","million t DM/yr",37.6858628,60.9418378,85.39494,87.06551,88.60948,90.04472,91.38681,92.6664,93.8253,94.77552
"GCAM 7.1","Reference","World","Agricultural Demand|Livestock","million t DM/yr",46.4323945,74.0494497,102.5594946,104.2511144,105.7572337,107.0904302,108.2633387,109.340218,110.283273,111.0036982
"GCAM 7.1","Reference","EU-12","Agricultural Demand|Livestock|Food","million t DM/yr",1.84219,1.67212,1.49107,1.57358,1.63179,1.67604,1.70746,1.72952,1.74345,1.75011
"GCAM 7.1","Reference","EU-15","Agricultural Demand|Livestock|Food","million t DM/yr",12.2127,12.853,13.1261,13.5948,14.0078,14.4097,14.8049,15.2161,15.6203,15.9724
"GCAM 7.1","Reference","World","Agricultural Demand|Livestock|Food","million t DM/yr",14.05489,14.52512,14.61717,15.16838,15.63959,16.08574,16.51236,16.94562,17.36375,17.72251
"GCAM 7.1","Reference","EU-12","Agricultural Demand|Livestock|Other","million t DM/yr",6.9043417,11.4354919,15.6734846,15.6120244,15.5159637,15.3696702,15.1690687,14.944298,14.714523,14.4780682
"GCAM 7.1","Reference","EU-15","Agricultural Demand|Livestock|Other","million t DM/yr",25.4731628,48.0888378,72.26884,73.47071,74.60168,75.63502,76.58191,77.4503,78.205,78.80312
"GCAM 7.1","Reference","World","Agricultural Demand|Livestock|Other","million t DM/yr",32.3775045,59.5243297,87.9423246,89.0827344,90.1176437,91.0046902,91.7509787,92.394598,92.919523,93.2811882
"GCAM 7.1","Reference","EU-12","Agricultural Production","million t DM/yr",261.100875310439,269.429300007827,295.924825081362,314.769265185606,328.598012061418,340.760570149419,352.641660229703,365.718905244915,380.173780898525,392.565210168238
"GCAM 7.1","Reference","EU-15","Agricultural Production","million t DM/yr",1006.44709633724,1077.53479630048,1121.23536874784,1191.4805877856,1242.89189631569,1299.08484918447,1340.18849048944,1394.5952603443,1463.58228544982,1516.49748014357
"GCAM 7.1","Reference","World","Agricultural Production","million t DM/yr",1267.54797164768,1346.9640963083,1417.1601938292,1506.24985297121,1571.48990837711,1639.84541933389,1692.83015071914,1760.31416558921,1843.75606634835,1909.0626903118
Binary file added examples/example2_v7.1_standardized.xlsx
Binary file not shown.
Binary file added examples/example3_v6.0.RData
Binary file not shown.
File renamed without changes.
Binary file added examples/example3_v7.1.RData
Binary file not shown.
4 changes: 3 additions & 1 deletion man/launch_gcamreport_ui.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dc71984

Please sign in to comment.