title: Plot many histograms using a for loop in R
body: <p>I have a .csv file with data like this:</p>
  
  <pre><code>         RI    Na   Mg   Al    Si    K    Ca   Ba   Fe Type
  1   1.51793 12.79 3.50 1.12 73.03 0.64  8.77 0.00 0.00  BWF
  2   1.51643 12.16 3.52 1.35 72.89 0.57  8.53 0.00 0.00  VWF
  3   1.51793 13.21 3.48 1.41 72.64 0.59  8.43 0.00 0.00  BWF
  4   1.51299 14.40 1.74 1.54 74.55 0.00  7.59 0.00 0.00  TBL
  5   1.53393 12.30 0.00 1.00 70.16 0.12 16.19 0.00 0.24 BWNF
  6   1.51655 12.75 2.85 1.44 73.27 0.57  8.79 0.11 0.22 BWNF
  </code></pre>
  
  <p>I want to create histograms for the distribution of each of the columns.
  I've tried this:</p>
  
  <pre><code>data&lt;-read.csv("glass.csv")
  names&lt;-(attributes(data)$names)
  for(name in names)
  {
      dev.new()
      hist(data$name)
  }
  </code></pre>
  
  <p>But i keep getting this error: <code>Error in hist.default(data$name) : 'x' must be numeric</code></p>
  
  <p>I'm assuming that this error is because <code>attributes(data)$names</code> returns a set of strings, <code>"RI"   "Na"   "Mg"   "Al"   "Si"   "K"    "Ca"   "Ba"   "Fe"   "Type"
  </code></p>
  
  <p>But I'm unable to convert them to the necessary format.</p>
  
  <p>Any help is appreciated!</p>