1

我正在编写一个包,它同时使用完全导入的 ggplot2 和 tidyquant:

#' @import ggplot2
#' @import tidyquant

后来在我的plot.object()函数中,我绘制了一个条形图

x %>%
    ggplot() +
        geom_barchart(
            aes(
                x = date,
                open = open,
                high = high,
                low = low,
                close = close
            )
        )

安装、加载和附加包后,我调用plot.object(),导致以下错误:

Error in eval(`_inherit`, env, NULL) : object 'GeomLinerange' not found

和回溯:

12. eval(`_inherit`, env, NULL) 
11. eval(`_inherit`, env, NULL) 
10. super() 
9.  fetch_ggproto(super(), name) 
8.  fetch_ggproto(x, name) 
7.  `$.ggproto`(geom, "aesthetics") 
6.  geom$aesthetics 
5.  as.vector(y) 
4.  intersect(names(params), geom$aesthetics()) 
3.  ggplot2::layer(stat = StatLinerangeBC, geom = GeomLinerangeBC, 
    data = data, mapping = mapping, position = position, show.legend = show.legend, 
    inherit.aes = inherit.aes, params = list(na.rm = na.rm, fill_up = fill_up, 
        fill_down = fill_down, color_up = color_up, color_down = color_down,  ... 
2.  geom_barchart(aes(x = date, open = open, high = high, low = low, 
    close = close)) at moex_candles-plot.R#61
1.  plot.object()

但是,如果在调用之前附加了 ggplo2 plot.object,则没有错误。

我怀疑这可能是一个 tidyquant 的错误,因为所有 ggplot2 函数都按预期工作,并且只有在tidyquant::geom_barchart()调用时才会发生错误。

或者我在导入魔法中缺少什么东西?

4

0 回答 0