title: Set day of week to be used by to.weekly
body: <p>I am trying to convert a time series of daily data (only business days) contained in an xts object into a time series of weekly data. Specifically, I want the resulting time series to contain the end of week entries (meaning last business day of a week) of the original data. I've been trying to achieve this using the function to.weekly of the xts package.</p>
  
  <p>In the discussion regarding another question (<a href="https://stackoverflow.com/q/7366011/878098">Wrong week-ending date using &#39;to.weekly&#39; function in &#39;xts&#39; package</a>) the below example code achieved exactly what I need. However, when I run the code, to.weekly uses Mondays as a representative for the weekly data.</p>
  
  <p>I am wondering which global setting might allow me to force to.weekly to use Friday as a week's representative.</p>
  
  <p>Example code:</p>
  
  <pre><code>library(lubridate); library(xts)   
  test.dates &lt;- seq(as.Date("2000-01-01"),as.Date("2011-10-01"),by='days')
  test.dates &lt;- test.dates[wday(test.dates)!=1 &amp; wday(test.dates)!=7] #Remove weekends
  test.data &lt;- rnorm(length(test.dates),mean=1,sd=2)
  test.xts &lt;- xts(x=test.data,order.by=test.dates)
  test.weekly &lt;- to.weekly(test.xts)
  test.weekly[wday(test.weekly, label = TRUE, abbr = TRUE) != "Fri"]
  </code></pre>