-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed min to 0 and max to very high value in EATLancet recommendati…
…on to simplify GAMS code. And linter fixes.
- Loading branch information
1 parent
c92b90c
commit 1358efe
Showing
7 changed files
with
46 additions
and
55 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: mrland | ||
Title: MadRaT land data package | ||
Version: 0.52.3 | ||
Date: 2023-12-20 | ||
Version: 0.52.4 | ||
Date: 2024-01-08 | ||
Authors@R: c( | ||
person("Jan Philipp", "Dietrich", , "[email protected]", role = c("aut", "cre")), | ||
person("Abhijeet", "Mishra", 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,51 +1,43 @@ | ||
#' Convert data from the EAT Lancet Comission | ||
#' | ||
#' Convert data from the EAT Lancet Comission to ISO country level. | ||
#' | ||
#' | ||
#' @title convertEATLancet | ||
#' @description Convert data from the EAT Lancet Commission to be used in MAgPIE | ||
#' | ||
#' @param x MAgPIE object containing EAT Lancet data at mixed country-region | ||
#' resolution | ||
#' @param subtype Type of EAT Lancet data that should be read. Available types are: | ||
#' \itemize{ | ||
#' \itemize{ | ||
#' \item \code{cons_data}: Consumption analysis ("EAT_Lancet_cons_data.csv") | ||
#' \item \code{recommend}: Food recommendations ("EAT_Lancet_recommendations.csv") | ||
#' } | ||
#' @return EAT Lancet data as MAgPIE object at ISO country level | ||
#' @author Isabelle Weindl | ||
#' @author Isabelle Weindl, Felicitas Beier | ||
#' @seealso \code{\link{readSource}} | ||
#' @examples | ||
#' | ||
#' \dontrun{ | ||
#' a <- readSource(type="EATLancet",subtype="cons_data") | ||
#' a <- readSource(type = "EATLancet", subtype = "cons_data") | ||
#' } | ||
#' @importFrom madrat getISOlist | ||
|
||
convertEATLancet <- function(x,subtype) { | ||
|
||
if(subtype == "cons_data"){ | ||
|
||
y <- toolAggregate(x, "regionmappingEATLancet.csv", weight=NULL ) | ||
|
||
} else if (subtype == "recommend") { | ||
|
||
iso <- getISOlist(type = "all") | ||
mapping <- cbind(rep("GLO",length(iso)),as.character(iso)) | ||
y <- toolAggregate(x, rel = mapping, weight=NULL ) | ||
|
||
} else { | ||
|
||
stop("Not a valid subtype!") | ||
|
||
} | ||
|
||
return(y) | ||
} | ||
|
||
|
||
convertEATLancet <- function(x, subtype) { | ||
|
||
if (subtype == "cons_data") { | ||
|
||
y <- toolAggregate(x, "regionmappingEATLancet.csv", weight = NULL) | ||
|
||
} else if (subtype == "recommend") { | ||
# replace NA's for min and max values | ||
x[, , "min"] <- ifelse(is.na(x[, , "min"]), 0, x[, , "min"]) | ||
x[, , "max"] <- ifelse(is.na(x[, , "max"]), 999999, x[, , "max"]) | ||
|
||
|
||
|
||
# expand to all iso countries | ||
iso <- getISOlist(type = "all") | ||
mapping <- cbind(rep("GLO", length(iso)), as.character(iso)) | ||
y <- toolAggregate(x, rel = mapping, weight = NULL) | ||
|
||
|
||
|
||
|
||
} else { | ||
|
||
stop("Not a valid subtype! Please select cons_data or recommend in readEATLancet function.") | ||
|
||
} | ||
|
||
return(y) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.