 <p>Try this:</p> <pre><code>&gt; d &lt;- as.Date("01-01-2013", "%d-%m-%Y") + 0:7 # first 8 days of 2013 &gt; d [1] "2013-01-01" "2013-01-02" "2013-01-03" "2013-01-04" "2013-01-05" [6] "2013-01-06" "2013-01-07" "2013-01-08" &gt; &gt; ufmt &lt;- function(x) as.numeric(format(as.Date(x), "%U")) &gt; ufmt(d) - ufmt(cut(d, "year")) + 1 [1] 1 1 1 1 1 2 2 2 </code></pre> <p><em>Note:</em> The first Sunday in the year is defined as the start of week 1 by <code>%U</code> which means that if the year does not start on Sunday then we must add 1 to the week so that the first week is week 1 rather than week 0. <code>ufmt(cut(d, "year"))</code> equals one if <code>d</code>'s year starts on Sunday and zero otherwise so the formula above reduces to <code>ufmt(d)</code> if d's year starts on Sunday and <code>ufmt(d)+1</code> if not.</p> <p>UPDATE: corrections so Jan starts at week 1 even if year starts on a Sunday, e.g. 2006. </p>