title: Can't compute covariance matrix on a data frame in R
body: <p>I have the following data set (which I import from a 6-column <strong>Excel file</strong> with a .csv file extension):</p>
  
  <pre><code>treas &lt;- read.csv(file = 'treas.csv', header = TRUE, stringsAsFactors = FALSE)
  
  2YR     3YR     5YR     7YR     10YR    30YR
  0.41    0.85    1.65    2.18    2.6     3.43
  0.41    0.85    1.65    2.2     2.61    3.45
  0.4     0.82    1.63    2.17    2.59    3.44
  0.41    0.86    1.66    2.19    2.6     3.44
  0.43    0.88    1.69    2.22    2.62    3.45
  0.45    0.93    1.71    2.24    2.64    3.47
  0.44    0.91    1.7     2.23    2.65    3.47
  0.42    0.88    1.66    2.17    2.58    3.41
  0.45    0.93    1.7     2.21    2.6     3.41
  0.49    0.95    1.71    2.21    2.61    3.4
  0.51    0.99    1.77    2.27    2.66    3.44
  0.48    0.95    1.71    2.21    2.61    3.43
  0.48    0.94    1.71    2.22    2.64    3.47
  0.5     0.94    1.71    2.22    2.63    3.44
  0.48    0.96    1.72    2.23    2.63    3.45
  0.49    0.95    1.7     2.19    2.59    3.41
  0.48    0.92    1.68    2.17    2.57    3.38
  0.46    0.9     1.64    2.14    2.53    3.35
  0.45    0.88    1.64    2.14    2.54    3.36
  0.47    0.88    1.62    2.13    2.53    3.34
  0.47    0.9     1.66    2.17    2.58    3.4
  0.49    0.95    1.71    2.22    2.64    3.46
  0.52    0.98    1.74    2.25    2.65    3.47
  0.52    1       1.74    2.24    2.63    3.44
  0.51    0.99    1.7     2.19    2.58    3.38
  0.51    0.97    1.68    2.17    2.57    3.37
  0.46    0.93    1.66    2.15    2.55    3.38
  0.48    0.92    1.65    2.13    2.53    3.34
  0.48    0.95    1.68    2.17    2.55    3.36
  </code></pre>
  
  <p>When I call the cov() method on the the <code>treas</code> data frame, I see the following error message:</p>
  
  <pre><code>Error: is.numeric(x) || is.logical(x) is not TRUE
  </code></pre>
  
  <p>To check the data types, I use:</p>
  
  <pre><code>sapply(treas, typeof)
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>        2YR         3YR         5YR         7YR        10YR        30YR 
  "character" "character" "character" "character" "character" "character" 
  </code></pre>
  
  <p>Calling <code>str(treas)</code> reveals:</p>
  
  <pre><code>str(treas)
  'data.frame':   1252 obs. of  6 variables:
   $ 2YR  : Factor w/ 235 levels ".","0.34","0.35",..: 8 8 7 8 10 12 11 9 12 16 ...
   $ 3YR  : chr w/ 219 levels ".","0.66","0.69",..: 18 18 15 19 21 26 24 21 26 28 ...
   $ 5YR  : chr w/ 207 levels ".","0.94","0.95",..: 67 67 65 68 71 73 72 68 72 73 ...
   $ 7YR  : chr w/ 192 levels ".","1.19","1.20",..: 96 98 95 97 100 102 101 95 99 99 ...
   $ 10YR : chr w/ 178 levels ".","1.37","1.38",..: 118 119 117 118 120 122 123 116 118 119 ...
   $ 30YR : chr w/ 125 levels ".","2.11","2.14",..: 121 123 122 122 123 125 125 120 120 119 ...
  </code></pre>
  
  <p>I've tried to force the data frame to numeric using:</p>
  
  <pre><code>lapply(treas, as.numeric)
  </code></pre>
  
  <p>But, doing so results in:</p>
  
  <pre><code>Warning messages:
  1: In lapply(treas, as.numeric) : NAs introduced by coercion
  2: In lapply(treas, as.numeric) : NAs introduced by coercion
  3: In lapply(treas, as.numeric) : NAs introduced by coercion
  4: In lapply(treas, as.numeric) : NAs introduced by coercion
  5: In lapply(treas, as.numeric) : NAs introduced by coercion
  6: In lapply(treas, as.numeric) : NAs introduced by coercion
  </code></pre>
  
  <p>Then, I still get the same error when calling <code>cov(treas)</code>:</p>
  
  <pre><code>Error: is.numeric(x) || is.logical(x) is not TRUE
  </code></pre>
  
  <p>Anyone see what I'm doing incorrectly here?  Thanks!</p>