makeAggregator {TxRegInfra} | R Documentation |
generate JSON to aggregate (counting records, and, by default, averaging a given variable) within a collection
makeAggregator(by = "chrom", vbl = "chromStart", opname = "average", op = "$avg")
by |
character(1) telling the field for stratifying records for aggregation |
vbl |
character(1) telling field with numerical value for which a statistic will be computed within strata defined by 'by' |
opname |
character(1) define the name of the aggregation |
op |
character(1) evaluating to a mongo aggregation operator like '$avg' or '$min' |
a JSON document as produced by rjson::toJSON
This produces json that can be used as an argument to m$aggregate() for m a mongolite::mongo instance
makeAggregator() if (interactive() & verifyHasMongoCmd()) { remURL = URL_txregInAWS() colls = listAllCollections( url=remURL, db = 'txregnet') m1 = mongo(url = remURL, db = 'txregnet', collection='CD14_DS17215_hg19_FP') # find minimum value of statistic 'stat' per chromosome newagg = makeAggregator( by='chr', vbl='stat', op='$min', opname='min') tab = m1$aggregate( newagg ) head(tab) }