简体   繁体   中英

Get data statistics in R with rmongodb or RMongo

Using robomongo I can get basic description of the data using

db.getCollection('Exempt').stats()

but i cannot seem to get this info in nR using the rmongodb or RMongo packages.

Can anyone please help?

Regards, Abhishek

You can get this information (and more) using library(mongolite) . The command you want is mongo$info()

library(mongolite)

mongo <- mongo(collection = "test", db = "test")
info <- mongo$info()
info$stats

# $ns
# [1] "test.test"
# 
# $count
# [1] 0
# 
# $size
# [1] 0
# 
# $storageSize
# [1] 8192
# 
# $numExtents
# [1] 1
# 
# $nindexes
# [1] 1
# 
# $lastExtentSize
# [1] 8192
# 
# $paddingFactor
# [1] 1
# 
# $systemFlags
# [1] 1
# 
# $userFlags
# [1] 1
# 
# $totalIndexSize
# [1] 8176
# 
# $indexSizes
# $indexSizes$`_id_`
# [1] 8176
# 
# 
# $ok
# [1] 1

rm(mongo); gc()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM