Skip to content

geom_density error when all groups are dropped #2282

@stla

Description

@stla

Hello,

library(ggplot2)
dat <- structure(list(include = c(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE
), Petal_Width = c(0.1234567, 1.4321, 1.5, 1.5, 1.3, 1.5), Species = c("setosa", 
"versicolor", "versicolor", "versicolor", "versicolor", "versicolor"
), Date = structure(c(1484524800, 1484611200, 1484697600, 1484784000, 
1484870400, 1485043200), class = c("POSIXct", "POSIXt"), tzone = "UTC")), .Names = c("include", 
"Petal_Width", "Species", "Date"), class = c("tbl_df", "tbl", 
"data.frame"), row.names = c(NA, -6L))
ggplot(dat, aes(x=Petal_Width)) + geom_density() + facet_wrap("Date")

This generates this error:

Error: Discrete value supplied to continuous scale
In addition: Warning messages:
1: Groups with fewer than two data points have been dropped. 
2: Groups with fewer than two data points have been dropped. 
3: Groups with fewer than two data points have been dropped. 
4: Groups with fewer than two data points have been dropped. 
5: Groups with fewer than two data points have been dropped. 
6: Groups with fewer than two data points have been dropped.

In fact, all groups are dropped. Then I think the error message is not very appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorlayers 📈

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions