Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Solid question. I was pulling my hair out until I found <a href="https://stackoverflow.com/questions/14153092/meaning-of-ddply-error-names-attribute-9-must-be-the-same-length-as-the-vec">this</a> which described an interesting "feature" of <code>plyr</code>. So this solution utilizes ggplot, plyr, reshape2- hopefully a good intro to R. If you need to add cuts through days you can also do that by adding a variable in the ddply(). </p> <pre><code>library(plyr) library(reshape2) library(ggplot2) Hs &lt;- read.table( header=TRUE, text=' dates times gaps 1 2013-06-10 15:40:02.654168 1.426180 2 2013-06-10 15:40:18.936882 2.246462 3 2013-06-10 15:40:35.215668 3.227132 4 2013-06-10 15:40:48.328785 1.331284 5 2013-06-10 15:40:53.809485 1.294128 6 2013-06-10 15:41:04.027745 2.292671 7 2013-06-10 16:41:25.876519 1.293501 8 2013-06-10 16:41:42.929280 1.342166 9 2013-06-10 16:42:11.700626 3.203901 10 2013-06-10 16:42:23.059550 1.304467') Hs$dates &lt;- paste(Hs$date, Hs$times, sep = " ") Hs$dates &lt;- strptime(Hs$date, "%Y-%m-%d %H:%M:%S") class(Hs$dates) # "POSIXlt" "POSIXt" Hs$h1 &lt;- Hs$dates$hour Hs$dates &lt;- as.POSIXct(strptime(Hs$date, "%Y-%m-%d %H:%M:%S")) class(Hs$dates) # "POSIXct" "POSIXt" library(ggplot2) ggplot(Hs, aes(factor(h1), gaps)) + geom_boxplot(fill="white", colour="darkgreen") # easy way! Traditional boxplot. ggplot(Hs, aes(factor(h1), gaps)) + geom_boxplot() + stat_boxplot(coef = 1.7, fill="white", colour="darkgreen") </code></pre> <p>I don't know if adding "coef = 1.7" works for you- if not continue further to create the values via a summary table</p> <pre><code>cuts &lt;- c(.03, .5, .97, 1) x &lt;- ddply(Hs, .(h1), function (x) {summarise(x, y = quantile(x$gaps, cuts))}) x$cuts &lt;- cuts x &lt;- dcast(x, h1 ~ cuts, value.var = "y") x.melt &lt;- melt(x, id.vars = "h1") </code></pre> <p>Here are the lines you requested plus another box plot just for fun. </p> <pre><code>ggplot(x.melt, aes(x = h1, y = value, color = variable)) + geom_point(size = 5) + geom_line() + scale_colour_brewer(palette="RdYlBu") + xlab("hours") ggplot(x, aes(factor(h1), ymin = 0, lower = `0.03`, middle = `0.5`, upper = `0.97`, ymax = `1`)) + geom_boxplot(stat = "identity", fill="white", colour="darkgreen") </code></pre> <p><img src="https://i.stack.imgur.com/8FykU.jpg" alt="geom_line"></p> <p><img src="https://i.stack.imgur.com/tiaQm.jpg" alt="custom boxplot"></p> <p>Hope this helps.</p>
    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