If you need names, then iterate over the names, not the values:
sapply(names(myDF), function(nm) hist(myDF[[nm]], main=nm))
Alternatively, iterate over names and values ββat the same time using mapply or Map :
Map(function(name, values) hist(values, main=name), names(myDF), myDF)
For the most part, you should not use deparse and substitute if you are not doing metaprogramming (if you do not know what it is, you do not).
source share