cannot run stat_density2d example

28 views
Skip to first unread message

Jyotirmoy B

unread,
Feb 26, 2010, 12:35:23 AM2/26/10
to ggplot2
When I try to run the following example from the documentation [http://
had.co.nz/ggplot2/stat_density2d.html]:

d <- ggplot(diamonds, aes(carat, price)) + xlim(1,3)
d + stat_density2d(geom="tile", aes(fill = ..density..), contour =
FALSE)

I get the error message

Error in `[<-.data.frame`(`*tmp*`, var, value = list(`NA` = NULL)) :
missing values are not allowed in subscripted assignments of data
frames

Changing line 31 in stat-density-2d.r from

names(df) <- c("x", "y", "density")

to
names(df) <- c("x", "y", "density","group")

fixes the problem and produces output similar to the documentation.

Was alerted to this by the following stackoverflow question
http://stackoverflow.com/questions/2333521/why-do-i-get-an-error-when-i-run-some-examples-from-the-online-ggplot2-reference

Jyotirmoy Bhattacharya


Jyotirmoy B

unread,
Feb 26, 2010, 12:37:10 AM2/26/10
to ggplot2
On Feb 26, 10:35 am, Jyotirmoy B <jmoy.mate...@gmail.com> wrote:
> When I try to run the following example from the documentation [http://
> had.co.nz/ggplot2/stat_density2d.html]:
>
> d <- ggplot(diamonds, aes(carat, price)) + xlim(1,3)
> d + stat_density2d(geom="tile", aes(fill = ..density..), contour =
> FALSE)
>
> I get the error message
>
> Error in `[<-.data.frame`(`*tmp*`, var, value = list(`NA` = NULL)) :
>   missing values are not allowed in subscripted assignments of data
> frames

Sorry for the previous post. Found out that it was a known bug:
http://groups.google.com/group/ggplot2/browse_thread/thread/6a7929d2b122efb2

Jyotirmoy Bhattacharya

Reply all
Reply to author
Forward
0 new messages