title: Tidyverse Parse Date String
body: <p>I have a "date" column in a data frame that has a space after the date. I want to <code>FIND</code> the space, then go <code>LEFT</code> to that position minus 1 spot, and convert that string into a date. This is a representative example: </p>
  
  <pre><code>library(tidyverse)
  library(lubridate)
  
  my_sales &lt;- c(10, 15, 20, 15)
  my_dates &lt;- c("12/30/02 0:00", "1/4/03 0:00", "1/11/03 0:00", "1/19/03 0:00")
  df &lt;- data.frame(my_sales, my_dates)
  df$my_dates &lt;- as.character(df$my_dates)
  
  df$my_dates_temp1 &lt;- str_sub(df$my_dates, 1, str_locate(df$my_dates, ' ')[, 1]-1)
  head(df)
  
  &gt;   my_sales      my_dates my_dates_temp1
  &gt; 1       10 12/30/02 0:00       12/30/02
  &gt; 2       15   1/4/03 0:00         1/4/03
  &gt; 3       20  1/11/03 0:00        1/11/03
  &gt; 4       15  1/19/03 0:00        1/19/03
  </code></pre>
  
  <p>My issue is when I try to convert <code>my_dates_temp1</code> to a date. </p>
  
  <p>Base R </p>
  
  <pre><code>as.Date(df$my_dates_temp1)
  &gt; Error in charToDate(x) : 
  &gt;   character string is not in a standard unambiguous format
  </code></pre>
  
  <p>lubridate</p>
  
  <pre><code>lubridate::as_date(df$my_dates_temp1)
  &gt; [1] NA NA NA NA
  &gt; Warning message:
  &gt; All formats failed to parse. No formats found. 
  </code></pre>
  
  <p>How is this not in a format that can be converted to a date and how can I convert it? </p>