Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- gcam-v7.0
- dev

jobs:
R-CMD:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker_impl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- gcam-v7.0
- dev

jobs:
build:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: draft-pdf

on:
push:
branches:
- gcam-v7.0

jobs:
paper:
runs-on: ubuntu-latest
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper/paper.md
- name: Upload
uses: actions/upload-artifact@v1
with:
name: paper
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: paper/paper.pdf
1 change: 1 addition & 0 deletions .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- gcam-v7.0
- dev

jobs:
test:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ prova*

inst/doc
*.tiff
tests/testthat/testInputs/v_7.0/database_basexdb_ref_gcamv7.0_test_specify_queries.dat
tests/testthat/testInputs/v_7.0/gcamv7.0_test_specify_queries_standardized.csv
tests/testthat/testInputs/v_7.0/gcamv7.0_test_specify_queries_standardized.RData
tests/testthat/testInputs/v_7.0/gcamv7.0_test_specify_queries_standardized.xlsx
8 changes: 3 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,25 @@ Authors@R: c(person("Rodés-Bachs", "Clàudia", email = "claudia.rodes@bc3resear
person("Van de Ven", "Dirk-Jan", 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.
URL: https://github.com/JGCRI/gcamreport
BugReports: https://github.com/JGCRI/gcamreport/issues
URL: https://github.com/bc3LC/gcamreport
BugReports: https://github.com/bc3LC/gcamreport/issues
Depends: R (>= 3.5.0)
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
Imports:
usethis,
knitr,
markdown,
rlang,
readr,
data.table,
magrittr,
dplyr,
tibble,
tidyr,
rgcam,
ggplot2,
stringr,
stringi,
here,
xml2,
shiny,
Expand All @@ -42,6 +39,7 @@ Imports:
rrapply (>= 1.2.6),
rpackageutils
Suggests:
knitr,
rprojroot,
rmarkdown,
testthat (>= 3.0.0),
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ RUN R -e "remotes::install_github('JGCRI/rgcam')"
RUN R -e "install.packages('knitr')"
RUN R -e "install.packages('markdown')"
RUN R -e "install.packages('readr')"
RUN R -e "install.packages('stringi')"
RUN R -e "install.packages('rlang')"
RUN R -e "install.packages('readr')"
RUN R -e "install.packages('data.table')"
Expand Down
35 changes: 35 additions & 0 deletions GCAM_KAIST7.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
devtools::load_all()





# available variable
available_variables()



# develop

generate_report(db_path ="E:/gcam-v7.0-Windows-Release-Package_GGS621/", # path to database under gcamreport folder
db_name = "testdb", # db folder name
scenarios = c('Reference', 'NZ_Electricity_Nuc_Policy'), ## scenario names
prj_name = "GCAM-KAIST7.dat", final_year = 2100,
desired_regions = c('South Korea', 'Japan'),
desired_variables = c(
#'Agricultural*',
#'Emissions*',
# 'Fertilizer',
#'Primary Energy*',
#'Secondary Energy*',
#'Final Energy*',
'GDP|MER', # MER in $2010USD
"GDP|PPP", # PPP in $2017USD
#'Land Cover*',
'Population'
# 'Forestry Demand',
#'Land Cover*'
# 'Value Added'
),
save_output = TRUE, launch_ui = TRUE)

21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 BC3 Low Carbon department

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 0 additions & 24 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export(load_query)
export(load_variable)
export(reset_first_load)
export(start_with_pattern)
export(transform_to_xml)
export(update_user_choices_plot)
import(dplyr)
import(ggplot2)
import(rgcam)
importFrom(data.table,as.data.table)
importFrom(dplyr,anti_join)
importFrom(dplyr,bind_rows)
importFrom(dplyr,distinct)
Expand Down
6 changes: 3 additions & 3 deletions R/app_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ check_user_choices_plot <- function(vars, scen, years, reg, grouped) {
#' @export
update_user_choices_plot <- function(selected_scen, selected_years,
tree_regions, tree_variables, sidebarItemExpanded) {

# get selected regions and variables from input
sel_reg_ini <- get_selected(tree_regions, format = "slices")
sel_vars_ini <- get_selected(tree_variables, format = "slices")
Expand Down Expand Up @@ -229,7 +230,7 @@ reset_first_load <- function() {
#' @keywords internal
#' @importFrom magrittr %>%
#' @importFrom dplyr filter select
#' @importFrom data.table as.data.table
#' @importFrom tibble as_tibble
#' @return subseted dataset
#' @export
do_data_sample <- function(sdata, sel_scen, sel_years, sel_cols, sel_vars, sel_reg,
Expand Down Expand Up @@ -260,7 +261,7 @@ do_data_sample <- function(sdata, sel_scen, sel_years, sel_cols, sel_vars, sel_r
filter(Variable %in% vars) %>%
filter(Region %in% reg) %>%
select(c(sel_cols, sel_years)) %>%
as.data.table()
as_tibble()

return(data_sample)
}
Expand Down Expand Up @@ -336,7 +337,6 @@ do_unmount_tree <- function(base_tree, type) {
na.omit <- NULL

if (length(base_tree) > 0) {
save(base_tree, file = "test_unmount_tree_variables.RData")
# transform dataset to list of items with delimiter |
ll <- rrapply(
base_tree,
Expand Down
26 changes: 26 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
#' queries_general
#'
#' @source local
#' @format vector
#' @description gcamreport queries compatible with GCAM 7.0 version.
#' Contain all queries except for nonCO2 queries
#' @examples
#' \dontrun{
#' library(gcamreport)
#' gcamreport::queries_general
#' }
"queries_general"

#' queries_nonCO2
#'
#' @source local
#' @format vector
#' @description gcamreport nonCO2 query compatible with GCAM 7.0 version.
#' @examples
#' \dontrun{
#' library(gcamreport)
#' gcamreport::queries_nonCO2
#' }
"queries_nonCO2"


#' emissions_list
#'
#' @source local
Expand Down
51 changes: 48 additions & 3 deletions R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ options(dplyr.summarise.inform = FALSE)
#########################################################################


#' transform_to_xml
#'
#' Return xml document from a given queries list
#' @param parsed_queries_list parsed list of queries
#' @return xml document containing the given queries list
#' @importFrom xml2 read_xml
#' @keywords internal utils
#' @export
transform_to_xml <- function(parsed_queries_list) {
queries <- lapply(parsed_queries_list, function(query) {
query_title <- query$title
query_xml <- paste("<aQuery>\n <all-regions/>\n", query$query, "</aQuery>\n", sep = "")
return(query_xml)
})
xml_string <- paste("<queries>", paste(queries, collapse = ""), "</queries>", sep = "")
xml_doc <- read_xml(xml_string)
return(xml_doc)
}

#' start_with_pattern
#'
#' Return the vector elements starting with the specified parameters
Expand Down Expand Up @@ -223,17 +242,43 @@ get_population <- function() {
#' @importFrom dplyr mutate select left_join rename
#' @importFrom magrittr %>%
#' @export




get_gdp_ppp <- function() {
value <- pop_mill <- NULL

GDP_PPP_clean <<-
getQuery(prj, "GDP per capita PPP by region") %>%
### Codes below need to be inside of function(), otherwise Build -> Install error (Ctrl+Shift+D)
ppp_row<<- getQuery(prj, "GDP per capita PPP by region") %>%
left_join(population_clean %>% rename(pop_mill = value), by = c("scenario", "region", "year")) %>%
mutate(
value = value * pop_mill * gcamreport::convert$conv_90USD_10USD,
value = value * pop_mill * gcamreport::convert$conv_90USD_10USD, #### $2010USD
var = "GDP|PPP") %>%
select(-pop_mill) %>%
filter(region !='South Korea')

ppp_kor <<-getQuery(prj, "GDP MER by region") %>% ## GDP MER by region unit is million 1990 USD
filter(region =="South Korea") %>%
left_join(PPP_MER_KOR, by ='year') %>%
mutate(
value = value * gcamreport::convert$conv_million_billion * #MER
gcamreport::convert$conv_90USD_17USD * #$2017USD
conversion_ratio, #MER to PPP
var = "GDP|PPP"
) %>%
select(-conversion_ratio)


GDP_PPP_clean <<-
bind_rows(ppp_row, ppp_kor) %>%
select(all_of(gcamreport::long_columns))

# GDP_PPP_clean <<-
# ppp_row %>% left_join(ppp_kor, by = c("scenario", "region", "year", "var", "Units")) %>%
# mutate(value = ifelse(region =="South Korea", value.y, value.x),
# var = "GDP|PPP") %>%
# select(all_of(gcamreport::long_columns))
}


Expand Down
4 changes: 2 additions & 2 deletions R/gcamreport.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' gcamreport
#'
#' \itemize{
#' \item Github: https://github.com/JGCRI/gcamreport
#' \item Webpage: https://jgcri.github.io/gcamreport/}
#' \item Github: https://github.com/bc3LC/gcamreport
#' \item Webpage: https://bc3lc.github.io/gcamreport/}
#'
#' @docType _PACKAGE
#' @name gcamreport
Expand Down
Loading