Created
July 30, 2016 03:58
-
-
Save infotroph/1db11d146dfb3d473151e6a8f9c0fca9 to your computer and use it in GitHub Desktop.
Reversing date axes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = data.frame( | |
date=as.Date(c("2016-07-31", "2016-08-01", "2016-08-03", "2016-08-04", "2016-08-10")), | |
x=rnorm(5)) | |
# Origin to use might be OS-specific? | |
num2date = function(x){as.character(as.Date(x, origin="1970-01-01"))} | |
(ggplot(a, aes(as.numeric(date), x)) | |
+geom_point() | |
+scale_x_reverse(labels=num2date) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment