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

Already on GitHub? Sign in to your account

Misleading error message from scale_x_discrete #783

Closed
izahn opened this Issue Mar 17, 2013 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

izahn commented Mar 17, 2013

The error generated when dates are passed to scale_x_discrete is misleading:

tmp <- data.frame(x = as.Date(c("2012-03-15", "2012-03-16", "2012-03-17")),
                  y = 1:3)
ggplot(tmp, aes(x=x, y=y)) +
  geom_line() +
  scale_x_discrete()

gives

Error: Discrete value supplied to continuous scale

The error is incorrect: the problem is that a Date was passed to a discrete scale, not that a discrete value was provided to a continuous scale.

R version 2.15.2 (2012-10-26)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] reshape2_1.2.2  ggplot2_0.9.3.1

loaded via a namespace (and not attached):
 [1] colorspace_1.2-1   compiler_2.15.2    dichromat_2.0-0    digest_0.6.3      
 [5] grid_2.15.2        gtable_0.1.2       labeling_0.1       MASS_7.3-23       
 [9] munsell_0.4        plyr_1.8           proto_0.3-10       RColorBrewer_1.0-5
[13] scales_0.2.3       stringr_0.6.2      tools_2.15.2      
Owner

hadley commented Feb 24, 2014

This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette.

@hadley hadley closed this Feb 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment