Skip to content
Prev 350963 / 398502 Next

print dataframe names in loop

On May 15, 2015, at 10:05 AM, Kai Mx wrote:

            
You do realize that the `for` function returns NULL, I hope? I was surprised when I learned this, although it is clearly stated in the help page.

Neither `lapply` nor `for` passes the names into the environment for evaluation:

for( d in dflist ) { z <- deparse(substitute(d)); print(z)}
[1] "d"
[1] "d"
[1] "d"

People would generally use this approach:

for (n in names(dflist) { ...do something with nm or dflist[[nm]]... }

-- 
David.