0

在我的包中,我喜欢创建一个马赛克图。在交互式会话中,这很好用。但是,如果我从新的 R 会话中调用该函数,devtools::load_all则会引发错误“提供给连续刻度的离散值”。

这是一个最小的工作示例:

test_ggmosaic <- function(dat) {
    dat <- datasets::mtcars
    p <- ggplot2::ggplot(data=dat)+
        ggmosaic::geom_mosaic(
            ggplot2::aes(weight=mpg,x=ggmosaic::product(gear, cyl), fill=mpg)
        ) +
        ggplot2::theme_bw()+
        ggplot2::scale_fill_discrete(guide=ggplot2::guide_legend(reverse=TRUE)
    )
    return(p)
}

现在,当此函数在包中定义ggplot2ggmosaic添加到文件中的Imports字段时DESCRIPTION,我在加载devtools和(通过load_all)函数所在的包后调用此函数,我得到错误

Fehler: Discrete value supplied to continuous scale

另一方面,当我第一次执行

library(ggplot2)
library(ggmosaic)

然后调用上面的函数,情节就出现了(在这个例子中没有多大意义)。

4

0 回答 0