title: How to use apply.daily/period.apply for calculating maximum per column in XTS time series?
body: <p>I have a problem using the <code>period.apply</code> function for my case of a high resolution time series analysis.</p>
  
  <p>I want to calculate statistics(Mean for different Periods, Stddev etc.) for my data which is in 10 min intervals. To calculate hourly means worked fine like described in <a href="https://stackoverflow.com/a/16019730/9735690">this answer</a>.</p>
  
  <p>It creates a new xts object with means calculated for each column.  How do I calculate maximum values for each column?</p>
  
  <p>This reproducible example describes the structure of my data:</p>
  
  <pre><code>library(xts)
  start &lt;- as.POSIXct("2018-05-18 00:00")
  tseq &lt;- seq(from = start, length.out = 1440, by = "10 mins")
  Measurings &lt;- data.frame(
    Time = tseq,
    Temp = sample(10:37,1440, replace = TRUE, set.seed(seed = 10)),
    Variable1 = sample(1:200,1440, replace = TRUE, set.seed(seed = 187)),
    Variable2 = sample(300:800,1440, replace = TRUE, set.seed(seed = 333))
  )
  Measurings_xts &lt;- xts(Measurings[,-1], Measurings$Time)
  HourEnds &lt;- endpoints(Measurings_xts, "hours")
  Measurings_mean &lt;- period.apply(Measurings_xts, HourEnds, mean)
  </code></pre>
  
  <p>I thought it would be easy to just change the function argument from <code>mean</code> to <code>max</code>, like this:</p>
  
  <pre><code>Measurings_max &lt;- period.apply(Measurings_xts, HourEnds, max)
  </code></pre>
  
  <p>It delivers output, but only one column with the overall maximum values. I need the hourly maximums of each column. A simple solution would be much appreciated.</p>