title: R - How to use rollapply on functions from other package like maxdrawdown from tseries?
body: <p>I am trying to use <code>rollapply</code> from zoo package with function <code>maxdrawdown</code> from tseries package:</p>
  
  <pre><code>library(zoo)
  library(tseries)
  x &lt;- c(1,2,4,6,7,10,8,6,5,4,6,7,8)
  y &lt;- zoo(x)
  z &lt;- rollapply(y,3,maxdrawdown,fill=NA,align="right")
  </code></pre>
  
  <p>However I get this error message:</p>
  
  <pre><code>Error in zoo(rval, index(x)[i]) : 
   “x” : attempt to define invalid zoo object
  </code></pre>
  
  <p>Does that mean I cannot use <code>rollapply</code> on function <code>maxdrawdown</code>? Is there alternative solution to work this out?</p>