You can use the .I
function in data.table
to get the row numbers and which.max
function to get the index of the maximum value. Here's an example:
main.r291 chars13 lines
In the above example, we first create a sample data.table
and then use the which.max
function on the specific row to find the column with the maximum value. We then use .I
and which.max
function to find the row number with the maximum value in a specific column.
gistlibby LogSnag