title: Read in Multiple Excel Files with Different Layouts in R
body: <p>I have a collection of a dozen excel files I am reading in to a list of dataframes in R with the following code:</p>
  
  <pre><code>data_path &lt;- "path"
  files &lt;- dir(data_path, pattern = "*.xlsx")
  
  data &lt;- files %&gt;%
    map(~readWorkbook(file.path(data_path, .), sheet = "Results"))
  </code></pre>
  
  <p>This grabs everything no problems. The issue is that I need them all in the same format for further manipulation and, due to a non-universal layout, some are imported like this:</p>
  
  <pre><code>X1     2016     2017     2018
  y       12       12       12
  </code></pre>
  
  <p>and others like this:</p>
  
  <pre><code>Result
  y         2016       2017       2018
  x          12         12         12
  </code></pre>
  
  <p>The reason is because some excel files are forwarded to me with an additional row at the top with the string character 'Results'</p>
  
  <p>Now I could fix this with direct surgery to each one:</p>
  
  <pre><code>names(data) &lt;- rbind(data[1,])
  names(data)[1] &lt;- "X1"
  data &lt;- data[-c(1),]
  </code></pre>
  
  <p>But this seems like a rather ugly hack solution that will lead to automation problems down the line. Is there a way to use the readWorkbook() function but specify to skip rows if they contain certain values?</p>
  
  <p>eg perhaps something like: </p>
  
  <pre><code>if value equal to 'Result' {
    skipRow()
  }
  </code></pre>
  
  <p>Or to search dataframes for rows of dates and use these as column names? </p>