Skip to content

Commit

Permalink
added producer price index
Browse files Browse the repository at this point in the history
  • Loading branch information
flohump committed Jun 24, 2024
1 parent d0abe0e commit 2847a13
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '5092864'
ValidationKey: '5113786'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'magpie4: MAgPIE outputs R package for MAgPIE version 4.x'
version: 2.5.6
date-released: '2024-06-20'
version: 2.5.7
date-released: '2024-06-24'
abstract: Common output routines for extracting results from the MAgPIE framework
(versions 4.x).
authors:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: magpie4
Title: MAgPIE outputs R package for MAgPIE version 4.x
Version: 2.5.6
Date: 2024-06-20
Version: 2.5.7
Date: 2024-06-24
Authors@R: c(
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")),
person("Florian", "Humpenoeder", , "[email protected]", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions R/getReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ getReport <- function(gdx, file = NULL, scenario = NULL, filter = c(1, 2, 7),
"reportConsumVal(gdx)",
"reportPriceFoodIndex(gdx,baseyear = 'y2010')",
"reportPriceFoodIndex(gdx,baseyear = 'y2020')",
"reportProducerPriceIndex(gdx)",
"reportExpenditureFoodIndex(gdx)",
"reportPriceAgriculture(gdx)",
"reportPriceBioenergy(gdx)",
Expand Down
42 changes: 21 additions & 21 deletions R/reportProducerPriceIndex.R
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
#' @title reportProducerPriceIndex
#' @description reports producer price index
#'
#'
#' @export
#'
#'
#' @param gdx GDX file
#' @return Producer price index as MAgPIE object Unit: see names
#' @author Isabelle Weindl, David M CHen
#' @param prod_groups whether to return only product groups

#' @import magpiesets
#' @examples
#'
#'
#' \dontrun{
#' x <- reportProducerPriceIndex(gdx)
#' }
#'
#'

reportProducerPriceIndex <- function(gdx, prod_groups = FALSE){

if (prod_groups) {
#read in data
primary <- priceIndex(gdx,level="regglo", products="kfo", baseyear = "y2020", type="producer")
crops <- priceIndex(gdx,level="regglo", products="kcr", baseyear = "y2020", type="producer")
livestock <- priceIndex(gdx,level="regglo", products="kli", baseyear = "y2020", type="producer")
bioenergy <- priceIndex(gdx,level="regglo", products=c("begr","betr"), baseyear = "y2020", type="producer")

#rename
getNames(primary) <- "Prices|Producer Price Index|Primary food products (Index 2020=100)"
getNames(crops) <- paste0("Prices|Producer Price Index|",reportingnames("kcr")," (Index 2020=100)",sep="")
getNames(livestock) <- paste0("Prices|Producer Price Index|",reportingnames("kli")," (Index 2020=100)",sep="")
getNames(bioenergy) <- "Prices|Producer Price Index|Bioenergy (Index 2020=100)"
out <- mbind(primary,crops,livestock,bioenergy)
getNames(primary) <- "Prices|Index2020|Agriculture|Producer|Primary food products (Index 2020=100)"
getNames(crops) <- paste0("Prices|Index2020|Agriculture|Producer|",reportingnames("kcr")," (Index 2020=100)",sep="")
getNames(livestock) <- paste0("Prices|Index2020|Agriculture|Producer|",reportingnames("kli")," (Index 2020=100)",sep="")
getNames(bioenergy) <- "Prices|Index2020|Agriculture|Producer|Bioenergy (Index 2020=100)"

out <- mbind(primary,crops,livestock,bioenergy)

} else {
pr <- priceIndex(gdx, level="regglo", products="kall", product_aggr = FALSE,
pr <- priceIndex(gdx, level="regglo", products="kall", product_aggr = FALSE,
baseyear = "y2020", type="producer")
getNames(pr, dim = 1) <- paste0("Prices|Producer Price Index|", reportingnames(getNames(pr, dim = 1)),

getNames(pr, dim = 1) <- paste0("Prices|Index2020|Agriculture|Producer|", reportingnames(getNames(pr, dim = 1)),
" (Index 2020=100)")
crops <- priceIndex(gdx,level="regglo", products="kcr", baseyear = "y2020", type="producer")
getNames(crops) <- paste0("Prices|Producer Price Index|",reportingnames("kcr")," (Index 2020=100)",sep="")
getNames(crops) <- paste0("Prices|Index2020|Agriculture|Producer|",reportingnames("kcr")," (Index 2020=100)",sep="")
livestock <- priceIndex(gdx,level="regglo", products="kli", baseyear = "y2020", type="producer")
getNames(livestock) <- paste0("Prices|Producer Price Index|",reportingnames("kli")," (Index 2020=100)",sep="")
getNames(livestock) <- paste0("Prices|Index2020|Agriculture|Producer|",reportingnames("kli")," (Index 2020=100)",sep="")
all <- priceIndex(gdx,level="regglo", products="kall", baseyear = "y2020", type="producer")
getNames(all) <- paste0("Prices|Producer Price Index|",reportingnames("kall")," (Index 2020=100)",sep="")
getNames(all) <- paste0("Prices|Index2020|Agriculture|Producer|",reportingnames("kall")," (Index 2020=100)",sep="")

out <- mbind(pr, crops)
out <- mbind(out, livestock)
out <- mbind(out, all)
}

return(out)
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MAgPIE outputs R package for MAgPIE version 4.x

R package **magpie4**, version **2.5.6**
R package **magpie4**, version **2.5.7**

[![CRAN status](https://www.r-pkg.org/badges/version/magpie4)](https://cran.r-project.org/package=magpie4) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158582.svg)](https://doi.org/10.5281/zenodo.1158582) [![R build status](https://github.com/pik-piam/magpie4/workflows/check/badge.svg)](https://github.com/pik-piam/magpie4/actions) [![codecov](https://codecov.io/gh/pik-piam/magpie4/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/magpie4) [![r-universe](https://pik-piam.r-universe.dev/badges/magpie4)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Leon Bodirsky <bodirsky@

To cite package **magpie4** in publications use:

Bodirsky B, Humpenoeder F, Dietrich J, Stevanovic M, Weindl I, Karstens K, Wang X, Mishra A, Beier F, Breier J, Yalew A, Chen D, Biewald A, Wirth S, von Jeetze P, Leip D, Crawford M, Alves M (2024). _magpie4: MAgPIE outputs R package for MAgPIE version 4.x_. doi:10.5281/zenodo.1158582 <https://doi.org/10.5281/zenodo.1158582>, R package version 2.5.6, <https://github.com/pik-piam/magpie4>.
Bodirsky B, Humpenoeder F, Dietrich J, Stevanovic M, Weindl I, Karstens K, Wang X, Mishra A, Beier F, Breier J, Yalew A, Chen D, Biewald A, Wirth S, von Jeetze P, Leip D, Crawford M, Alves M (2024). _magpie4: MAgPIE outputs R package for MAgPIE version 4.x_. doi:10.5281/zenodo.1158582 <https://doi.org/10.5281/zenodo.1158582>, R package version 2.5.7, <https://github.com/pik-piam/magpie4>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {magpie4: MAgPIE outputs R package for MAgPIE version 4.x},
author = {Benjamin Leon Bodirsky and Florian Humpenoeder and Jan Philipp Dietrich and Miodrag Stevanovic and Isabelle Weindl and Kristine Karstens and Xiaoxi Wang and Abhijeet Mishra and Felicitas Beier and Jannes Breier and Amsalu Woldie Yalew and David Chen and Anne Biewald and Stephen Wirth and Patrick {von Jeetze} and Debbora Leip and Michael Crawford and Marcos Alves},
year = {2024},
note = {R package version 2.5.6},
note = {R package version 2.5.7},
url = {https://github.com/pik-piam/magpie4},
doi = {10.5281/zenodo.1158582},
}
Expand Down

0 comments on commit 2847a13

Please sign in to comment.