Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>good to see fellow Debian old-timers here :) Your answer is already pretty nice. As I happen to work a lot with time series, I thought I'd throw in a variant using the excellent <a href="http://cran.r-project.org/package=zoo" rel="nofollow noreferrer">zoo</a> and <a href="http://cran.r-project.org/package=xts" rel="nofollow noreferrer">xts</a> packages. The latter builds on top of the former and has, among other things, the <code>period.apply()</code> function we can use here along with the <code>endpoints()</code> function to get you two-hourly aggregates.</p> <p>So at the top I'd use</p> <pre><code>library(zoo) # for zoo objects library(xts) # for period.apply gcdata &lt;- read.table("http://bernd.eckenfels.net/view/gc1001.ygc.csv", header=TRUE, sep=",", dec=".") timestamps &lt;- gcdata$Timestamp + as.POSIXct(strptime("2012-01-01 00:00:00", format="%Y-%m-%d %H:%M:%S")) gcdatazoo &lt;- zoo(gcdata[-1], order.by=timestamps) # as zoo object </code></pre> <p>to create a <code>zoo</code> object. Your function remains:</p> <pre><code>plotAreaCorridor &lt;- function(x, y, col.poly1="lightgray", col.poly2="gray",...) { x.pol &lt;- c(x, rev(x), x[1]) y.pol &lt;- c(y[,1], rev(y[,5]),y[,1][1]) plot(x, y[,6]+1, type="n", ...) polygon(x.pol, y.pol, col=col.poly1, lty=0) x.pol &lt;- c(x, rev(x), x[1]) y.pol &lt;- c(y[,2], rev(y[,4]), y[,1][1]) polygon(x.pol, y.pol, col=col.poly2, lty=0) lines(x, y[,3], col="blue") # median lines(x, y[,6], col="red") # max invisible(NULL) } </code></pre> <p>And we can then simplify a little:</p> <pre><code>agg &lt;- period.apply(gcdatazoo[,"Pause.s."], # to which data INDEX=endpoints(gcdatazoo, "hours", k=2), # every 2 hours FUN=function(x) quantile(x, # what fun. probs=c(5,20,50,80,95,100)/100)) #v99 = q99(gcdata$Pause.s.) # what is q99 ? v99 &lt;- mean(agg[,5]) # mean of 95-th percentile? plotAreaCorridor(index(agg), # use time index as x axis coredata(agg), # and matrix part of zoo object as data ylim=c(0,max(agg[,5])*1.5), ylab="Quantiles of GC events", main="NewPar Collection Activity") abline(h=median(gcdatazoo[,"Pause.s."]), col="lightblue") abline(h=v99, col="grey") labeltxt &lt;- paste("99%=",round(v99,digits=3),"s n=", nrow(gcdatazoo),sep="") text(x=index(agg)[20], y=1.5*v99, labeltxt, col="grey", pos=3) # or legend() </code></pre> <p>which gives </p> <p><img src="https://i.stack.imgur.com/Qo1Ph.png" alt="enter image description here"></p> <p>The axis is now automatic and shows weekdays only as the span is less than week; this can be override as needed.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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