R - by() and data.table: select data frame on > 1 criterion (e.g. select min start and max end)

26 Aug 2017

With data.table:

data.table(tmpDF)[,.(min(start), max(end)), .(gene_id)]

With by:

do.call(rbind, by(inData, inData$start, function(x) x[which.min(x$end),]))
do.call(rbind, by(tmpDF, tmpDF$gene_id, function(x) c(min(x$start), max(x$end))))
[ R  function  data_frame  ]