title: R - Merge two elements of a list in an iterative pdf task
body: <p>For a pdf mining task in R, I need your help.</p>
  <p>I wish to mine 1061 multi-page pdf files with the file names <code>pdf_filenames</code>, for which I would like to extract the content of the first two pages of each pdf file.</p>
  <p>So far, I have managed to get the content of all pdf files using the <code>map</code> function from the <code>purrr</code> library and <code>pdf_text</code> function from <code>pdftools</code> library.</p>
  <pre><code>&gt; pdfs = pdf_filenames %&gt;% 
          map(pdf_text)
  </code></pre>
  <p>This outputs a list with each element of the list representing one pdf file. The structure of the <code>pdfs</code> list is:</p>
  <pre><code>&gt; str(pdfs)
  List of 1061
   $ : chr [1:3] &quot;Content page 1_pdf1&quot; &quot;Content page 2_pdf1&quot; &quot;Content page 3_pdf1&quot;
   $ : chr [1:4] &quot;Content page 1_pdf2&quot; &quot;Content page 2_pdf2&quot; &quot;Content page 3_pdf2&quot; &quot;Content page 4_pdf2&quot;
   $ : chr [1:2] &quot;Content page 1_pdf3&quot; &quot;Content page 2_pdf3&quot;
   .
   .
   .
  </code></pre>
  <p>My desired output is:</p>
  <pre><code>List of 1061
   $ : chr [1:2] &quot;Content page 1_pdf1 Content page 2_pdf1&quot; &quot;Content page 3_pdf1&quot;
   $ : chr [1:3] &quot;Content page 1_pdf2 Content page 2_pdf2&quot; &quot;Content page 3_pdf2&quot; &quot;Content page 4_pdf2&quot;
   $ : chr [1:1] &quot;Content page 1_pdf3 Content page 2_pdf3&quot;
   .
   .
   .
  </code></pre>
  <p>I tried this <code>map</code> function</p>
  <pre><code>&gt; pdfs = pdf_filenames %&gt;% 
          map(pdf_text) %&gt;%
          map(c(1,2))
  </code></pre>
  <p>but that returned an empty list.</p>
  <pre><code>&gt; pdfs
  [[1]]
  NULL
  
  [[2]]
  NULL
  
  [[3]]
  NULL
  .
  .
  .
  </code></pre>
  <p>Appreciate your help very much! Thanks!</p>