title: Converting Factor to Date without creating NA's
body: <p>I'm running into problems converting factor to date; it is making NA values which I don't want.</p>
  
  <p>Data for my problem can be found here: (<a href="https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2Factivity.zip" rel="nofollow">https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2Factivity.zip</a>)</p>
  
  <pre><code>x &lt;- read.csv("activity.csv")
  head(x)
  
  steps       date interval
  1    NA 2012-10-01        0
  2    NA 2012-10-01        5
  3    NA 2012-10-01       10
  4    NA 2012-10-01       15
  5    NA 2012-10-01       20
  6    NA 2012-10-01       25
  </code></pre>
  
  <p>Goal: I'm trying to find the mean total number of steps taken per day.  So first, I need to <strong>bin values so that each data point corresponds to the sum for a given day</strong></p>
  
  <pre><code>x$Day &lt;- as.Date(cut(x$date, breaks = "day"))
  
  Error in cut.default(x$date, breaks = "day") : 'x' must be numeric
  </code></pre>
  
  <p>Just confirm this with <em>class</em> function</p>
  
  <pre><code>class(x[,2])
  </code></pre>
  
  <p>"factor"</p>
  
  <p>This is weird because from the head(x) above it looked like it was Date. Anyways so in order to bin values so that each data point corresponds to the sum for a given day using the <em>cut</em> function I need to change the date's to "Date" class</p>
  
  <pre><code>x[,2] &lt;- as.Date(x[,2], format="%Y/%m/%d")
  class(x[,2])
  </code></pre>
  
  <p>[1] "Date"</p>
  
  <p>OK, so in theory I should be able to bin values now</p>
  
  <pre><code>x$Day &lt;- as.Date(cut(x$date, breaks = "day"))
  </code></pre>
  
  <p>Error in seq.int(0, to0 - from, by) : 'to' cannot be NA, NaN or infinite
  In addition: Warning messages:
  1: In min.default(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,  :
    no non-missing arguments to min; returning Inf
  2: In max.default(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,  :
    no non-missing arguments to max; returning -Inf</p>
  
  <pre><code>head(is.na(x))
  
  steps date interval
  [1,]  TRUE TRUE    FALSE
  [2,]  TRUE TRUE    FALSE
  [3,]  TRUE TRUE    FALSE
  [4,]  TRUE TRUE    FALSE
  [5,]  TRUE TRUE    FALSE
  [6,]  TRUE TRUE    FALSE
  </code></pre>
  
  <p>If I compare this to what I saw prior to the <code>x[,2] &lt;- as.Date(x[,2], format="%Y/%m/%d")</code></p>
  
  <pre><code>head(is.na(x))
  
  steps  date interval
  [1,]  TRUE FALSE    FALSE
  [2,]  TRUE FALSE    FALSE
  [3,]  TRUE FALSE    FALSE
  [4,]  TRUE FALSE    FALSE
  [5,]  TRUE FALSE    FALSE
  [6,]  TRUE FALSE    FALSE
  </code></pre>
  
  <p>Not sure what's going on here? I know this should work because I got this idea from the following tutorial (<a href="http://blog.mollietaylor.com/2013/08/plot-weekly-or-monthly-totals-in-r.html?m=1" rel="nofollow">http://blog.mollietaylor.com/2013/08/plot-weekly-or-monthly-totals-in-r.html?m=1</a>)</p>
  
  <pre><code>sessionInfo()
  
  R version 3.0.3 (2014-03-06)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  
  locale:
  [1] LC_COLLATE=English_Canada.1252 
  [2] LC_CTYPE=English_Canada.1252   
  [3] LC_MONETARY=English_Canada.1252
  [4] LC_NUMERIC=C                   
  [5] LC_TIME=English_Canada.1252    
  
  attached base packages:
  [1] stats     graphics  grDevices utils    
  [5] datasets  methods   base     
  
  other attached packages:
  [1] scales_0.2.4  ggplot2_1.0.0
  
  loaded via a namespace (and not attached):
  [1] colorspace_1.2-4 digest_0.6.4    
  [3] grid_3.0.3       gtable_0.1.2    
  [5] MASS_7.3-29      munsell_0.4.2   
  [7] plyr_1.8.1       proto_0.3-10    
  [9] Rcpp_0.11.1      reshape2_1.4    
  [11] stringr_0.6.2    tools_3.0.3   
  </code></pre>