我需要创建一个桑基图(此处的代码:https ://gist.github.com/aaronberdanier/1423501 ),其中我的输入标签是成分,输出是成品。例如,我的输入是“政策分析”、“政策流程”、“政策评估”,而我的损失是“政策制定”。在
SankeyR(inputs,losses,unit,labels)
我的输入损耗和单位应该是多少?
我需要创建一个桑基图(此处的代码:https ://gist.github.com/aaronberdanier/1423501 ),其中我的输入标签是成分,输出是成品。例如,我的输入是“政策分析”、“政策流程”、“政策评估”,而我的损失是“政策制定”。在
SankeyR(inputs,losses,unit,labels)
我的输入损耗和单位应该是多少?
对于那些不知道的人,桑基图显示了一个过程的输入和损失是如何相关的。从 Github 存储库中的代码链接到一个很好的示例:http: //leniwiki.epfl.ch/index.php/DrawSankey
来自 Github 代码:
# OPTIONS:
# 'inputs' is a vector of input values
# 'losses' is a vector of loss values
# 'unit' is a string of the unit
# 'labels' is a vector of the labels for inputs and losses
# 'format' is the type of plotting:
此外,代码中还列出了一个示例。它已被注释掉,但这里是:
# EXAMPLE:
# Try using these values for the global carbon cycle, from Schlesinger (1997):
# inputs = c(120,92)
# losses = c(45,75,90,1,6)
# unit = "GtC/yr"
# labels = c("GPP","Ocean assimilation","Ra","Rh","Ocean loss","LULCC","Fossil fuel emissions")
# SankeyR(inputs,losses,unit,labels)
所以,如果我们下载代码,获取它并像这样运行它......
inputs = c(120,92)
losses = c(45,75,90,1,6)
unit = "GtC/yr"
labels = c("GPP","Ocean assimilation",
"Ra","Rh","Ocean loss","LULCC","Fossil fuel emissions")
png("SankeyPlot.png",
width = 960, height = 480, units = "px",
pointsize = 6,
res = 300,
type = c("quartz"))
SankeyR(inputs,losses,unit,labels)
dev.off()
我们得到了这个可爱的情节。
因此,从这个例子中应该清楚的是,前两个标签指的是输入,而该向量的其余部分指的是损失。此示例中的单位是每年的碳十亿吨,但可以通过为“单位”赋予不同的值来进行更改。