Skip to content
Prev 157727 / 398498 Next

"tapply versus by" in function with more than 1 arguments

The first tapply in your question subsets V1 but not V2 so they are
of different length.  To subset both tapply over the row names and
perform the subsetting in the function:

tapply(rownames(dataf), dataf$class, function(r) cor(dataf[r, "V1"],
dataf[r, "V2"]))

or

tapply(rownames(dataf), dataf$class, function(r) with(dataf[r, ], cor(V1, V2)))
On Wed, Oct 1, 2008 at 8:21 AM, C?zar Freitas <cafanselmo12 at yahoo.com.br> wrote: