> or with l_ply (plyr package)
> l_ply(data.frame(a=1:3, b=2:4), function(x) print(deparse(substitute(x))))
The best way to do this is to supply both the object you want to
iterate over, and its names. Unfortunately it's slightly difficult to
create a data structure of the correct form to do this with m_ply.
df <- data.frame(a=1:3, b=2:4)
input <- list(x = df, name = names(df))
inputdf <- structure(input,
class = "data.frame",
row.names = seq_along(input[[1]]))
m_ply(inputdf, function(x, name) {
cat(name, "---------\n")
print(x)
})
I'll think about how to improve this for a future version.
Hadley
--
http://had.co.nz/
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.