<p>Here's a better way to do what you want in R:</p>

<pre><code>categ &lt;- c(CO = "cat:stat.CO", #I'm naming these elements so
           ME = "cat:stat.ME", #  that the corresponding elements
           TH = "cat:stat.TH", #  in the list are named as well.
           ML = "cat:stat.ML") #  Could also just set 'names(doi_list)' to 'categ'.

doi_list &lt;- 
  lapply(categ, function(ctg)
    (doi &lt;- arxiv_search(ctg)$doi)[nchar(doi) &gt; 0])
</code></pre>

<p>I sort of threw you in the deep end on the last line with in-line assignment of <code>doi</code>; a more step-by-step approach would be:</p>

<pre><code>lapply(categ, function(ctg){
  arxiv.df &lt;- arxiv_search(ctg)
  doi &lt;- arxiv.df$doi
  doi[nchar(doi) &gt; 0]})
</code></pre>
Why is my list empty after execution?
<p>I managed to fill my <code>doi_list</code> but it does not work if I encapsulate the code into a <code>function</code>. <a href="http://www.r-bloggers.com/call-by-reference-in-r/" rel="nofollow">From a tutorial</a> I've seen I assume that this should be possible but <code>doi_list</code> is empty after <code>get_doi_from_category()</code> finishes.</p>

<pre><code>library(aRxiv)

get_doi_from_category &lt;- function(category, doi_list) {

  arxiv_rec &lt;- arxiv_search(category)
  arxiv_doi_list &lt;- arxiv_rec[13]

  by(arxiv_doi_list, 1:nrow(arxiv_doi_list), 
     function(row) { 
       if(nchar(row) &gt; 0) {
         doi_list &lt;&lt;- c(doi_list, row)
       }
     })
}

doi_list &lt;- list()

get_doi_from_category('cat:stat.ML', doi_list)

for(doi in doi_list) 
{
  print(doi)
} 

get_doi_from_category('cat:stat.CO', doi_list)
get_doi_from_category('cat:stat.ME', doi_list)
get_doi_from_category('cat:stat.TH', doi_list)
</code></pre>

<p>PS: First day with <strong>R</strong>.</p>