title: Convert daily to weekly where week starts on every Tuesday in R
body: <p>Here is the code: EDIT: SEE REPRODUCIBLE CODE BELOW</p>
  
  <pre><code>&gt;require("quantmod")   
  &gt;
  &gt; corn &lt;- as.xts(read.zoo("~/CORN.csv", sep=",", format ="%m/%d/%Y", header=TRUE))
  &gt; 
  &gt; head(corn)
             [,1]
  1962-01-03 4.03
  1962-01-04 3.99
  1962-01-05 4.02
  1962-01-08 4.03
  1962-01-09 4.05
  1962-01-10 4.07
  &gt; 
  &gt; corn &lt;- to.weekly(corn)[,4]
  &gt; 
  &gt; head(corn)
             corn.Close
  1962-01-05       4.02
  1962-01-12       4.08
  1962-01-19       4.11
  1962-01-26       4.11
  1962-02-02       4.08
  1962-02-09       4.05
  </code></pre>
  
  <p>How do you start every week on Tuesday? Something along the lines of </p>
  
  <pre><code>indexAt='startof("Tuesday")'
  </code></pre>
  
  <p>where indexAt is a parameter variable in the to.weekly() function.  </p>
  
  <p>The purpose for this is to line up with weekly COT data. </p>
  
  <p>EDIT ##################</p>
  
  <p>I've created some confusion by not providing reproducible code, so here is some with a partial solution incorporated based on suggestions by J. Winchester below:</p>
  
  <pre><code>&gt; getSymbols("GLD")
  [1] "GLD"
  &gt; GLD &lt;- GLD[,4]
  &gt; head(GLD, n=2)
             GLD.Close
  2007-01-03     62.28
  2007-01-04     61.65
  &gt; tues &lt;- weekdays(time(GLD)) == "Tuesday"
  &gt; gold &lt;- merge(GLD, tues)
  &gt; head(gold, n=5)
             GLD.Close tues
  2007-01-03     62.28    0
  2007-01-04     61.65    0
  2007-01-05     60.17    0
  2007-01-08     60.48    0
  2007-01-09     60.85    1
  </code></pre>