我将ggalluvial与ggplot2一起使用,不过,我希望能够在不附加ggalluvial的情况下生成相同的绘图,但只指定它与ggalluvial::一起使用。如果没有附加,我会得到以下错误:Error: Can't find stat called "stratum"。
d <- data.frame(
status = rep(c("state1","state2","state3"), rep(90, times=3)),
cellIndex = rep(seq_len(90), times=3),
cellCategory = c(rep(letters[seq_len(3)], each=30),
rep(letters[c(2,3,1)], each=30),
rep(letters[c(3,1,2)], each=30))
)
ggplot2::ggplot(data=d, ggplot2::aes(x=status, stratum=cellCategory, alluvium=cellIndex,
fill=cellCategory, label=cellCategory)) +
ggalluvial::geom_flow(stat="alluvium", lode.guidance="rightleft", color="darkgray") +
ggalluvial::geom_stratum() +
ggplot2::geom_text(stat="stratum", size=3)发布于 2018-12-16 07:11:48
这是一个困难的问题-深入code for ggplot2,stat参数粘贴您给定的字符串,然后在您所处的环境中查找该对象(在本例中为"StatStratum")。因为您不想加载包,所以它将无法找到它(并且无法更改参数本身)。
回答
因此,您需要像这样保存来自ggalluvia包对象:
StatStratum <- ggalluvial::StatStratum然后让剩下的代码保持原样。
https://stackoverflow.com/questions/53797744
复制相似问题