title: Using lapply to convert a single dataframe column to numeric in a list of dataframes
body: <p>I have a list of dataframes,  each df having three columns all of which are of type <code>character</code>. What I want is to use <code>lapply</code> (or another<code>*apply</code> function) and <code>as.numeric</code> to convert the 'heart attack' column to numeric but to also preserve the other variables in each dataframe.</p>
  
  <p>Here is sample data:</p>
  
  <pre><code>data &lt;- structure(list(AK = structure(list(hospital = c("HOS_3", "HOS_4"
  ), state = c("AK", "AK"), `heart attack` = c("13.4", "17.7")), .Names = c("hospital", 
  "state", "heart attack"), row.names = 3:4, class = "data.frame"), 
  AL = structure(list(hospital = c("HOS_1", "HOS_2"), state = c("AL", 
  "AL"), `heart attack` = c("14.3", "18.5")), .Names = c("hospital", 
  "state", "heart attack"), row.names = 1:2, class = "data.frame"), 
  AR = structure(list(hospital = c("HOS_5", "HOS_6"), state = c("AR", 
  "AR"), `heart attack` = c("15.6", "16.9")), .Names = c("hospital", 
  "state", "heart attack"), row.names = 5:6, class = "data.frame")), .Names = c("AK", 
  "AL", "AR"))
  </code></pre>
  
  <p>Looks like this:</p>
  
  <pre><code>&gt; data
  $AK
  hospital state heart attack
  3    HOS_3    AK         13.4
  4    HOS_4    AK         17.7
  
  $AL
  hospital state heart attack
  1    HOS_1    AL         14.3
  2    HOS_2    AL         18.5
  
  $AR
  hospital state heart attack
  5    HOS_5    AR         15.6
  6    HOS_6    AR         16.9
  </code></pre>
  
  <p>I want the exact same structure back but just with 'heart attack' column as numeric. Here is what I have tried so far (based on other SO posts and the ?docs and playing around) and a comment explaining what is going wrong:</p>
  
  <pre><code>lapply(c, function(x) x[3] &lt;- as.numeric(x[[3]])) # returns list of num vectors. Dropped other cols
  lapply(c, function(x) x[[3]] &lt;- as.numeric(x[[3]])) # returns list of num vectors. Dropped other cols
  rapply(c, as.numeric, classes = 'character', how='list') # Correct structure in output but converts all other cols to NA
  sapply(c, function(x) x[,3] &lt;- as.numeric(x[,3])) # returns list of num vectors. Dropped other cols
  lapply(c, function(x) lapply(x[,3], as.numeric)) # returns list of num vectors of single length
  lapply(c, lapply, as.numeric([[3]])) # error unexpected '[[
  lapply(c, function(x) {x[[3]] &lt;- as.numeric(x[[3]])})# returns list of num vectors. Dropped other cols
  lapply(c, lapply, as.numeric, [,3]) # error unexpected '[
  </code></pre>
  
  <p>Help much appreciated! Also, I would like to just use base R (if possible) so would prefer not to have to bring in another library (security issues at work - they don't always allow). Many thanks.</p>