2. I then created the mongo connection and tested to see if it is working properly. A value of “TRUE” confirmed it.
mongonew <- mongo.create()
mongonew
## [1] 0
## attr(,"mongo")
## <pointer: 0x00000000080909b8>
## attr(,"class")
## [1] "mongo"
## attr(,"host")
## [1] "127.0.0.1"
## attr(,"name")
## [1] ""
## attr(,"username")
## [1] ""
## attr(,"password")
## [1] ""
## attr(,"db")
## [1] "admin"
## attr(,"timeout")
## [1] 0
mongo.is.connected(mongonew)
## [1] TRUE
6. I concluded by testing several queries. I first checked the count and records of my local airport DTW, finding to no surprise one record. Then I tested the altitude of 645 and again just pulled up the airport of DTW. I then queried the count and a few records at sea level, followed by queries for >=2000 feet and <0.
mongo.count(mongonew, mnew, query ='{"faa":"DTW"}')
## [1] 1
mongo.find.all(mongonew, mnew, query = '{"faa":"DTW"}')
## [[1]]
## [[1]]$`_id`
## [1] "571d2e07f5665d650f02a068"
##
## [[1]]$faa
## [1] "DTW"
##
## [[1]]$name
## [1] "Detroit Metro Wayne Co"
##
## [[1]]$lat
## [1] 42.212
##
## [[1]]$lon
## [1] -83.353
##
## [[1]]$alt
## [1] 645
##
## [[1]]$tz
## [1] -5
##
## [[1]]$dst
## [1] "A"
mongo.find.all(mongonew, mnew, query = '{"alt":645}')
## [[1]]
## [[1]]$`_id`
## [1] "571d2e07f5665d650f02a068"
##
## [[1]]$faa
## [1] "DTW"
##
## [[1]]$name
## [1] "Detroit Metro Wayne Co"
##
## [[1]]$lat
## [1] 42.212
##
## [[1]]$lon
## [1] -83.353
##
## [[1]]$alt
## [1] 645
##
## [[1]]$tz
## [1] -5
##
## [[1]]$dst
## [1] "A"
mongo.count(mongonew, mnew, query = '{"alt":0}')
## [1] 49
mongo.find.all(mongonew, mnew, query = '{"alt":0}', limit=5)
## [[1]]
## [[1]]$`_id`
## [1] "571d2e07f5665d650f029f57"
##
## [[1]]$faa
## [1] "AGN"
##
## [[1]]$name
## [1] "Angoon Seaplane Base"
##
## [[1]]$lat
## [1] 57.504
##
## [[1]]$lon
## [1] -134.59
##
## [[1]]$alt
## [1] 0
##
## [[1]]$tz
## [1] -9
##
## [[1]]$dst
## [1] "A"
##
##
## [[2]]
## [[2]]$`_id`
## [1] "571d2e07f5665d650f029f6b"
##
## [[2]]$faa
## [1] "ALZ"
##
## [[2]]$name
## [1] "Alitak Seaplane Base"
##
## [[2]]$lat
## [1] 56.899
##
## [[2]]$lon
## [1] -154.25
##
## [[2]]$alt
## [1] 0
##
## [[2]]$tz
## [1] -9
##
## [[2]]$dst
## [1] "A"
##
##
## [[3]]
## [[3]]$`_id`
## [1] "571d2e07f5665d650f029f77"
##
## [[3]]$faa
## [1] "AOS"
##
## [[3]]$name
## [1] "Amook Bay Seaplane Base"
##
## [[3]]$lat
## [1] 57.471
##
## [[3]]$lon
## [1] -153.82
##
## [[3]]$alt
## [1] 0
##
## [[3]]$tz
## [1] -9
##
## [[3]]$dst
## [1] "A"
##
##
## [[4]]
## [[4]]$`_id`
## [1] "571d2e07f5665d650f029f7d"
##
## [[4]]$faa
## [1] "AQC"
##
## [[4]]$name
## [1] "Klawock Seaplane Base"
##
## [[4]]$lat
## [1] 55.555
##
## [[4]]$lon
## [1] -133.1
##
## [[4]]$alt
## [1] 0
##
## [[4]]$tz
## [1] -9
##
## [[4]]$dst
## [1] "A"
##
##
## [[5]]
## [[5]]$`_id`
## [1] "571d2e07f5665d650f029f88"
##
## [[5]]$faa
## [1] "ATT"
##
## [[5]]$name
## [1] "Camp Mabry Austin City"
##
## [[5]]$lat
## [1] 30.317
##
## [[5]]$lon
## [1] -97.767
##
## [[5]]$alt
## [1] 0
##
## [[5]]$tz
## [1] -6
##
## [[5]]$dst
## [1] "A"
mongo.count(mongonew, mnew, query = '{"alt":{"$gte":2000}}')
## [1] 187
mongo.find.one(mongonew, mnew, query = '{"alt":{"$gte":2000}}')
## _id : 7 571d2e07f5665d650f029f15
## faa : 4
## 0 : 2 2G9
##
## name : 4
## 0 : 2 Somerset County Airport
##
## lat : 4
## 0 : 1 40.039000
##
## lon : 4
## 0 : 1 -79.015000
##
## alt : 4
## 0 : 16 2275
##
## tz : 4
## 0 : 16 -5
##
## dst : 4
## 0 : 2 A
mongo.count(mongonew, mnew, query = '{"alt":{"$lt":0}}')
## [1] 2
mongo.find.all(mongonew, mnew, query = '{"alt":{"$lt":0}}')
## [[1]]
## [[1]]$`_id`
## [1] "571d2e07f5665d650f02a176"
##
## [[1]]$faa
## [1] "IPL"
##
## [[1]]$name
## [1] "Imperial Co"
##
## [[1]]$lat
## [1] 32.834
##
## [[1]]$lon
## [1] -115.58
##
## [[1]]$alt
## [1] -54
##
## [[1]]$tz
## [1] -8
##
## [[1]]$dst
## [1] "A"
##
##
## [[2]]
## [[2]]$`_id`
## [1] "571d2e07f5665d650f02a291"
##
## [[2]]$faa
## [1] "NJK"
##
## [[2]]$name
## [1] "El Centro Naf"
##
## [[2]]$lat
## [1] 32.829
##
## [[2]]$lon
## [1] -115.67
##
## [[2]]$alt
## [1] -42
##
## [[2]]$tz
## [1] -8
##
## [[2]]$dst
## [1] "A"