Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>How about this approach?</p> <pre><code>require("ggplot2") dtstring &lt;- c( "2011-09-28 03:33:00", "2011-08-24 13:41:00", "2011-09-19 16:14:00", "2011-08-18 11:01:00", "2011-09-17 06:35:00", "2011-08-15 12:48:00" ) dtPOSIXct &lt;- as.POSIXct(dtstring) # extract time of 'date+time' (POSIXct) in hours as numeric dtTime &lt;- as.numeric(dtPOSIXct - trunc(dtPOSIXct, "days")) p &lt;- qplot(dtTime) + xlab("Time slot") + scale_x_datetime(format = "%S:00") print(p) </code></pre> <p>The calculation, <code>dtPOSIXct - trunc(dtPOSIXct, "days")</code>, extracts time of POSIXct class objects in hours.</p> <p><img src="https://i.stack.imgur.com/ouqqe.png" alt="plot(p)"></p> <p>For <code>ggplot2-0.9.1</code>:</p> <pre><code>require("ggplot2") require("scales") dtstring &lt;- c( "2011-09-28 03:33:00", "2011-08-24 13:41:00", "2011-09-19 16:14:00", "2011-08-18 11:01:00", "2011-09-17 06:35:00", "2011-08-15 12:48:00" ) dtPOSIXct &lt;- as.POSIXct(dtstring) # extract time of 'date+time' (POSIXct) in hours as numeric dtTime &lt;- as.numeric(dtPOSIXct - trunc(dtPOSIXct, "days")) p &lt;- qplot(dtTime) + xlab("Time slot") + scale_x_datetime(labels = date_format("%S:00")) print(p) </code></pre> <p>For <code>ggplot2-0.9.3.1</code>:</p> <pre><code>require("ggplot2") require("scales") dtstring &lt;- c( "2011-09-28 03:33:00", "2011-08-24 13:41:00", "2011-09-19 16:14:00", "2011-08-18 11:01:00", "2011-09-17 06:35:00", "2011-08-15 12:48:00" ) dtPOSIXct &lt;- as.POSIXct(dtstring) # extract time of 'date+time' (POSIXct) in hours as numeric dtTime &lt;- as.numeric(dtPOSIXct - trunc(dtPOSIXct, "days")) class(dtTime) &lt;- "POSIXct" p &lt;- qplot(dtTime) + xlab("Time slot") + scale_x_datetime(labels = date_format("%S:00")) print(p) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload