R convert date into Julian day
<p>I want to convert dates into Julian day </p>

<pre><code>x &lt;- c('5/5/2007')
# convert to day of year (Julian date) 

strptime(x, "%m/%d/%Y")$yday+1 
#125
</code></pre>

<p>There are two things I do not understand in this: </p>

<p>1) What is <code>y$day + 1</code> doing? </p>

<p>When I run it for more dates, it gives me NA for some dates.</p>

<pre><code>date&lt;-c("09/06/1997","01/06/1998","26/05/1999","02/06/2000","01/06/2001","06/06/2002","05/06/2003",
    "21/05/2004","16/06/2005","27/05/2006","08/06/2007","09/06/1997","01/06/1998")

strptime(date, "%m/%d/%Y")$yday+1 
[1] 249   6  NA  37   6 157 126  NA  NA  NA 218 249   6
</code></pre>

<p>I am not sure why is this happening? And why do we need <code>$yday+1</code></p>