title: How to convert certain columns only to numeric?
body: <p>How can I convert <strong>certain</strong> columns only in a data frame to numeric?</p>
  
  <p>For instance, I have this data frame:</p>
  
  <pre><code>structure(list(airport = c("EGLL", "EGLL"), xdate = c("2016-07-28", 
  "2016-07-31"), ws = c("6", "5"), wd = c("237", "299"), humidity = c("68", 
  "55")), .Names = c("airport", "xdate", "ws", "wd", "humidity"
  ), row.names = 1:2, class = "data.frame")
  </code></pre>
  
  <p>I just want to convert <code>ws</code>, <code>wd</code>, and <code>humidity</code> to numeric, <strong>not</strong> <code>airport and xdate</code>.</p>
  
  <p>If I do this:</p>
  
  <pre><code>columns &lt;- sapply(weatherDF, is.character)
  weatherDF[, columns] &lt;- lapply(weatherDF[, columns, drop = FALSE], function(x) as.numeric(as.character(x)))
  </code></pre>
  
  <p>I am converting <code>airport</code> and <code>xdate</code> to numberic, and then I get this warning:</p>
  
  <pre><code>Warning messages:
  1: In FUN(X[[i]], ...) : NAs introduced by coercion
  2: In FUN(X[[i]], ...) : NAs introduced by coercion
  </code></pre>
  
  <p>And now my data frame has become:</p>
  
  <pre><code>structure(list(airport = c(NA_real_, NA_real_), xdate = c(NA_real_, 
  NA_real_), ws = c(6, 5), wd = c(237, 299), humidity = c(68, 55
  )), .Names = c("airport", "xdate", "ws", "wd", "humidity"), row.names = 1:2, class = "data.frame")
  </code></pre>
  
  <p>Any ideas how I can convert them properly?</p>