for loop over dataframe without indices
On Fri, 19 Dec 2003, Gabor Grothendieck wrote:
What I now realize is that the thing that is oddly missing in R is that you can't do an apply over the rows of a dataframe (at least not without having it coerced to an array and the elements coerced to possibly different types). The documentation does point this out. Its not a bug but its an omission that seems deserving of being addressed.
Since mapply() applies a function to each 'row' of a list of vectors, ou
can achieve this effect with
do.call("mapply", list(FUN,data.frame))
and also as a degenerate case of by():
by(data.frame, row.names(data.frame), FUN)
These should probably be documented under apply()
-thomas