Discrete data for ggplot stat_density2d

stat_density2d does not seem to like discrete data. My following code cannot be plotted and has such errors in R 2.15.2:

Error in contour lines (x = sorting (unique (data $ x)), y = sort (unique (data $ y)) :: own matrix 'z' is not defined In addition: Warning messages: 1: 10,000 rows containing non-final values ​​(stat_contour). 2: In min (x): no min arguments missing; returning Inf 3: In max (x): not missing max arguments; return -Inf

In R 2.15.3, the error is:

Error in function (x, y, h, n = 25, lims = c (range (x), range (y))):
bandwidths must be strictly positive

Probably due to the limitation of n = 25.

a<-url("http://www-personal.umich.edu/~ajing/Files/TestData.RData")
load(a)

library(ggplot2)
p1<-ggplot(myd, aes(x=xvar,y=yvar)) + stat_density2d(aes(fill=..level..), geom="polygon")
gt <- ggplot_gtable(ggplot_build(p1))

, ? 2D-?

, ggplot , .

+5

All Articles