How to name a column while creating a data frame using a name stored in a variable? <p>Trying to create a data.frame like this:</p> <pre><code>a = "foo" bar = data.frame(a = 1:3) </code></pre> <p>But the name of the column is <code>a</code>, not <code>foo</code>:</p> <pre><code>&gt; bar a 1 1 2 2 3 3 </code></pre> <p>The column can be renamed after creating data.frame, but how to easily assign it's name by a variable just in the same data.frame command?</p>