title: How do I fix an as.date error with origin?
body: <p>I am trying to run a code to calculate time series for when companies will merge. I keep getting the error:
  Error in <code>mutate()</code>:
  ! Problem while computing
  <code>X1 = as.Date(X1)</code>.
  Caused by error in <code>as.Date.numeric()</code>:
  ! 'origin' must be supplied
  Backtrace:</p>
  <ol>
  <li>df %&gt;% ...</li>
  <li>base::as.Date.numeric(X1)</li>
  <li>base::stop(&quot;'origin' must be supplied&quot;)</li>
  </ol>
  <p>I have tried several different things but cannot figure out what is wrong. Here is my code:</p>
  <pre><code> tech[which.max(tech$time),]
  merge_freq%&gt;%
    ggplot(aes(prop_in_year, reorder(`Parent.Company`,prop_in_year,median)))+
    geom_bar(stat='identity', fill='lightgreen')+
    labs(title='Merging Proporbility in every month in one year',
         x='Proporbility',
         y='Company')+
    theme_bw()
  set.seed(100)
  
  nxt_merge&lt;-function(prop){
    if(prop&lt;1){
      draw&lt;-c(rep(1,prop*1000), rep(0,(1-prop)*1000))
      if (draw[sample(1000,1)] == 1)
        return (T)
      else
        return (F)
    }
    else
      return(T)
  }
  
  prop_nxt&lt;-tech%&gt;%
    group_by(`Parent.Company`)%&gt;%
    summarise(time = time[which.max(time)])%&gt;%
    mutate(prop_mth = merge_freq$prop_in_year)
  
  df &lt;- data.frame(matrix(ncol = 10, nrow = 14))
  for( i in 1:10){
    df[i]&lt;-unlist(lapply( prop_nxt$prop_mth, nxt_merge))
  }
  
  df&lt;-prop_nxt[,-3]%&gt;%cbind(df)
  
  for( i in 1:14){
    for( j in 3:12){
      if(df[i,j] == T)
        df[i,j] = AddMonths(df[i,j-1],1)
      else
        df[i,j] = df[i,j-1]
    }
  }
  
  
  df&lt;-tibble(df)
  df&lt;-df%&gt;%
    mutate( X1 = as.Date(X1), 
            X2 = as.Date(X2),
            X3 = as.Date(X3),
            X4 = as.Date(X4),
            X5 = as.Date(X5),
            X6 = as.Date(X6),
            X7 = as.Date(X7),
            X8 = as.Date(X8),
            X9 = as.Date(X9),
            X10 = as.Date(X10))
  </code></pre>