title: Extracting tables from pdf in R
body: <p>I need to extract tables from a pdf. Here's the link</p>
  
  <p><a href="https://ainfo.cnptia.embrapa.br/digital/bitstream/item/155505/1/doc-202-1.pdf" rel="nofollow noreferrer">https://ainfo.cnptia.embrapa.br/digital/bitstream/item/155505/1/doc-202-1.pdf</a></p>
  
  <p>I want to extract tables from page 15 - page 21. All of these tables have the same structure (18 columns) and headings. Here's a snapshot of a single table.
        <a href="https://i.stack.imgur.com/eHiLq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eHiLq.jpg" alt="enter image description here"></a></p>
  
  <p>In each table, I am only interested in columns 6 - 8 and 17 column:  <code>Ciclo</code>, <code>Graus Dias/dias</code>, Epcaja de Plantion<code>and</code>Regiao de adaptacao`</p>
  
  <p>Here's what I did:      </p>
  
  <pre><code>library(dplyr)
  library(tabulizer)
  
  out &lt;- extract_tables("mydocument.pdf"), pages = c(15:21))
  
  # this gives me a list of 7 tables. 
  
  temp &lt;- data.frame(out[[1]]) # taking the first table as an example
  temp %&gt;% dplyr::select(X3, X4, X5, X12) # these are the columns corresponding to `Ciclo`, `Graus Dias/dias`, Epcaja de Plantion` and `Regiao de adaptacao`
  
  # this is a snapshot of first table
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/KKmIU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KKmIU.jpg" alt="enter image description here"></a></p>
  
  <p>However, when I extract the 7th table: </p>
  
  <pre><code>  temp &lt;- data.frame(out[[7]])
  
  #  Column 1: 4 are merged into a single column. 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/P0gtb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P0gtb.jpg" alt="enter image description here"></a></p>
  
  <p>In summary, the <code>extract_tables</code> function is not doing consistent column position and merging columns in some tables. How Can I fix it such that I have<br>
  a combined table with columns Ciclo<code>,</code>Graus Dias/dias<code>, Epcaja de Plantion</code> and <code>Regiao de adaptacao</code>  in one csv file. </p>