as.ggplot: as.ggplot

View source: R/as.ggplot.R

as.ggplotR Documentation

as.ggplot

Description

Converts a MAgPIE object or a list of MAgPIE objects into a dataframe usable for ggplot

Usage

as.ggplot(x,scenario="default",asDate=T,rev=F,useDimNames=FALSE)

Arguments

x

MAgPIE object or list of MAgPIE objects. For a list of MAgPIE objects the name of the list entry (has to be character) is used as scenario name.

scenario

Name of the scenario (only used if x is not a list) or position of the entry in the third dimension that contains the scenario name (only if the scenario name is stored in the third dimension) or NULL (automatic detection)

asDate

Format the years as date (TRUE) or keep as is (FALSE); deprecated (only kept for compatibility with older scripts)

rev

reverse legend order (TRUE) or not (FALSE)

useDimNames

Use dim names of 3rd dimension instead Data1, Data2, Data3, Data4; works only if x is a MAgPIE object (no list) and scenario=NULL

Value

Dataframe usable for ggplot

Author(s)

Florian Humpenoeder, David Klein

Examples


## Not run: 
as.ggplot(croparea(gdx))
## End(Not run)
## Not run: 
prices <- list()
prices[["Scenario1"]] <- prices("Scenario1.gdx",crops=c("tece","maiz"))
prices[["Scenario2"]] <- prices("Scenario2.gdx",crops=c("tece","maiz"))
as.ggplot(prices)
## End(Not run)

pik-piam/luplot documentation built on Jan. 29, 2025, 12:30 a.m.