Truncating dates (and other date-time manipulations)
On Fri, Sep 12, 2008 at 10:53 AM, Jeff Ryan <jeff.a.ryan at gmail.com> wrote:
I'm still not entirely sure I follow the desired usage, as the original post made no reference to ggplot2, but as Gabor mentioned the yearmon etc stuff is quite useful.
Well, I said "I need to be able to correct draw date-time scales", which means I need to be able to deal with a wide range of date time data types. I wasn't really aware of xts before - I'll definitely look into it in more detail.
If you are formatting arbitrary precision dates, take a look at axTicksByTime in xts. Both xts and quantmod use it for plotting. The core calculation is from ?endpoints I think the effect is what you desire --- though the logic of the function may be more than you want/need. I use it within the package(s) to make intelligent breaks given the periodicity of the data.
That's exactly what I want! I've written my own method, but I think you've done a much nicer job. (Although I draw minor grid lines as well) I'll definitely look at using that function in a future version of ggplot2.
Some examples are at: http://www.quantmod.com http://www.quantmod.com
Very nice - however, I'm philosophically opposed to special purpose plotting functions!
Most of the functions you have written are somewhere within xts already. At least the functionality is. See the vignette: http://cran.r-project.org/web/packages/xts/index.html http://cran.r-project.org/web/packages/xts/index.html
Including the ceiling and floor functions? That's what I'm really interested in. Hadley