title: Converting daily stock returns to annual returns using a panel data set in R
body: <p>I have a panel data set in R with daily stock returns. The data looks like:</p>
  
  <pre><code>company code  company name          date   daily return
             1             A    1990-09-01            0.1
             1             A    1990-09-02           0.05
             2             B    1990-09-01           0.01
             2             B    1990-09-02           0.05
  </code></pre>
  
  <p>How can I convert this data into annual stock returns for each company for each year? I tried converting the data into an <code>xts</code> object and tried to use <code>Return.annualized</code> function but it did not work.</p>