title: Create separate vectors for each of a data frame's columns (variables)
body: <p>Goal:  Take a data frame and create separate vectors for each of its columns (variables).</p>
  
  <p>The following code gets me close:</p>
  
  <pre><code>batting &lt;- read.csv("mlb_2014.csv", header = TRUE, sep = ",")
  hr &lt;- batting[(batting$HR &gt;= 20 &amp; batting$PA &gt;= 100), ]
  var_names &lt;- colnames(hr)
  for(i in var_names) {
  path &lt;- paste("hr$", i, sep = "")
  assign(i, as.vector(path))
  }
  </code></pre>
  
  <p>It creates the a vector for each column in the data frame as shown by the output below:</p>
  
  <pre><code>&gt; ls()
   [1] "AB"          "Age"         "BA"          "batting"     "BB"          "CS"         
   [7] "G"           "GDP"         "H"           "HBP"         "hr"          "HR"         
   [13] "i"           "IBB"         "Lg"          "Name"        "OBP"         "OPS"        
   [19] "OPS."        "PA"          "path"        "Pos.Summary" "R"           "RBI"        
   [25] "SB"          "SF"          "SH"          "SLG"         "SO"          "TB"         
   [31] "Tm"          "var_names"   "X2B"         "X3B"        
  </code></pre>
  
  <p>So far so good until you call one of the vectors. For example:</p>
  
  <pre><code>AB
  [1] "hr$AB"
  </code></pre>
  
  <p>Alas, all that is created is a one element character vector. When what I want it to create is this...</p>
  
  <pre><code>&gt; AB &lt;- as.vector(hr$AB)
  &gt; AB
  [1] 459 456 506 417 492 496 404 430 497 346 494 501 415 370 500 331 501 539 456 443 316 437
  [23] 449 526 349 486 432 480 295 489 354 506 315 471
  </code></pre>
  
  <p>...for each variable in the original data frame.</p>
  
  <p>How do I get R to recognize the elements in the character vector "path" as objects to call in the assign function, rather than an individual character element to assign to the vector I'm creating? I would like to keep this within the loop frame work, since the main motivation behind this project is teach my self how to use loops.</p>
  
  <p>Thanks!</p>