I would like to use the tapply() function on a dataframe, grouping the rows with the indexing. My problem is that the argument I would pass to the function is not a single column, but a pair of columns. This beacause the 2 columns of the data frame represent x-y points, which are intended as couples. Running tapply(dataframe , indexes , function) gives me the error that indexes has length different from tapply. How can I solve this? Thank you!