Get just a variable name in each iteration using an apply
<p>I'm using <code>lapply()</code> with a function but, instead of get an only one name of a variable in each iteration, I'm getting every variable names from my data set.</p>

<pre><code>colnames(data) &lt;- c("var1", "var2")

varnames &lt;- function(var, name){
   return(name)
}

print(lapply(data, varnames, name=names(data)))
</code></pre>

<p>I get this output:</p>

<pre><code>$var1
[1] "var1" "var2"

$var2
[1] "var1" "var2"
</code></pre>

<p>But, I'd like to get:</p>

<pre><code>$var1
[1] "var1"

$var2
[1] "var2"
</code></pre>