calc中的calc()函数错误

时间:2018-05-09 11:00:55

标签: r ggplot2 density-plot

我正在使用(http://ggplot2.tidyverse.org/reference/geom_density_2d.html#computed-variables)的示例来生成密度图。但是,我有以下错误:

library(ggplot2)
library(raster)
dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
d <- ggplot(dsmall, aes(x, y))
d + stat_density_2d(geom = "raster", aes(fill = calc(density)), contour = FALSE)

# Error in (function (classes, fdef, mtable)  : 
# unable to find an inherited method for function ‘calc’ for signature    
# ‘"standardGeneric", "missing"’

我错过了什么吗? density是否有一些预先计算的对象?

有人可以帮忙吗?

0 个答案:

没有答案