Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geom_density gives confusing error when a group has only one observation #676

Closed
wch opened this issue Sep 27, 2012 · 1 comment · Fixed by #702
Closed

geom_density gives confusing error when a group has only one observation #676

wch opened this issue Sep 27, 2012 · 1 comment · Fixed by #702
Milestone

Comments

@wch
Copy link
Member

wch commented Sep 27, 2012

dat <- data.frame(x=rnorm(7), g=c("a","a","a","b","b","b","c"))
ggplot(dat, aes(x=x, colour=g)) + geom_density()
#Error in rowSums(vapply(x, is.finite, logical(nrow(x)))) : 
#  'x' must be an array of at least two dimensions
#Error in UseMethod("scale_dimension") : 
#  no applicable method for 'scale_dimension' applied to an object of class "NULL"


# For an even simpler version:
dat <- data.frame(x=3, g="a")
ggplot(dat, aes(x=x)) + geom_density()
@wch
Copy link
Member Author

wch commented Oct 24, 2012

It actually gives this error when there are < 3 observations:

# Error
dat <- data.frame(x=3)
ggplot(dat, aes(x=x)) + geom_density()

# Error
dat <- data.frame(x=3:4)
ggplot(dat, aes(x=x)) + geom_density()

# OK
dat <- data.frame(x=3:5)
ggplot(dat, aes(x=x)) + geom_density()

@wch wch mentioned this issue Oct 24, 2012
@wch wch closed this as completed in b6f6c42 Oct 24, 2012
@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant