Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Many thanks to Roman for his help. This is the way we ended up doing it.</p> <pre><code>flow&lt;-read.table("iv.txt",comment.char="#",header=TRUE) Q&lt;-as.data.frame(c(0,(60*diff(flow$wt,1,1)/0.5))) # Q is used for flow in the standard names(Q)&lt;-"Q" # Now combine them l&lt;-list(flow,Q) dflow&lt;-as.data.frame(l) t1flow&lt;-subset(dflow, dflow$secs&gt;60*60 &amp; dflow$secs&lt;=120*60) # require the second hour of the data t1flow$QE&lt;-((t1flow$Q-setflow)/setflow)*100 # calculate the error library(TTR) # use this for moving averages # # Avert your eyes! I know there must be a slicker way of doing this ..... # # Calculate the moving average using a sample rate of every 4 readings (2 mins of 30sec readings) QE2&lt;-SMA(t1flow$QE,4) minQE2&lt;-min(QE2,na.rm=TRUE) maxQE2&lt;-max(QE2,na.rm=TRUE) # now for the 5 minute window QE5&lt;-SMA(t1flow$QE,10) minQE5&lt;-min(QE5,na.rm=TRUE) maxQE5&lt;-max(QE5,na.rm=TRUE) # Set window to 11 mins QE11&lt;-SMA(t1flow$QE,22) minQE11&lt;-min(QE11,na.rm=TRUE) maxQE11&lt;-max(QE11,na.rm=TRUE) # Set window to 19 mins QE19&lt;-SMA(t1flow$QE,38) minQE19&lt;-min(QE19,na.rm=TRUE) maxQE19&lt;-max(QE19,na.rm=TRUE) # Set window to 31 mins QE31&lt;-SMA(t1flow$QE,62) minQE31&lt;-min(QE31,na.rm=TRUE) maxQE31&lt;-max(QE31,na.rm=TRUE) # # OK - you can look again :-) # # create a data frame from this data trump&lt;-data.frame(c(2,5,11,19,31),c(minQE2,minQE5,minQE11,minQE19,minQE31),c(maxQE2,maxQE5,maxQE11,maxQE19,maxQE31)) names(trump)&lt;-c("T","minE","maxE") A&lt;-mean(t1flow$QE) # calculate the overall mean percentage error error_caption&lt;-paste("overall percentage error = ",A,"%") # create the string to label the error line # plot the graph ggplot(trump, aes(x = T, y = minE)) + geom_line() + geom_point(color="red") + geom_line(aes(y = maxE)) + geom_point(aes(y = maxE),colour="red") + geom_hline(aes(yintercept = 0), linetype = "dashed") + # overall percentage error geom_hline(aes(yintercept = A), linetype = "solid") + # set rate xlab("Observation windows (in minutes)") + ylab("% error") + scale_x_continuous(breaks=c(0,2,5,11,19,31),limits=c(0,32)) + # label the x axis only at the window values annotate("text", x = 10, y = A-0.5, label = error_caption) + # add the error line label opts(title="Trumpet curve for Test Data") </code></pre> <p><img src="https://i.stack.imgur.com/Mwp6o.png" alt="Final Trumpet Graph"></p> <p>Also available hYou can see the final graph [here][2]</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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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