-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
30 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters