This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MongoDB shell version v3.4.10 | |
connecting to: mongodb://127.0.0.1:27017/m121 | |
MongoDB server version: 3.4.10 | |
Chapter 3 Lab Lookup Pipelines Performance Comparison | |
## start on air_alliances - using $filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# initialization file (not found) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Course Data Scientist - Exploratory Data Analysis - Course Project 1 | |
# compare the different methods of reading in | |
# the file "household_power_consumption.txt" and | |
# subsetting Date to 1/2/2007 and 2/2/2007 | |
library(data.table) | |
library(sqldf) | |
Sys.setlocale(category = "LC_MESSAGES", locale = "C") # english output of system.time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wk4 PA.R R script for Prog Assign - week 4 | |
# load the data set and create contigency table c | |
# for grouped petal width (col 4) and species col 5 | |
fname <- 'wk4 dataset_390_1.txt' | |
colnames <- c('SL','SW','PL','PW','Species') | |
ds <- read.csv( fname, header = FALSE, sep = "\t", col.names=colnames) | |
breaks <- c(0.0, 0.5, 1.5, 2.0, 99.0) # right border included | |
ds$PWc <- cut(ds$PW, breaks=breaks, right = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// reference: https://groups.google.com/forum/?fromgroups=&hl=pt-BR#!topic/mongodb-user/h2N5v8gwi6M | |
// | |
db.recip.drop(); | |
db.recip.insert({_id:"B",i:[1,2,3,4,5,6]}); | |
db.recip.insert({_id:"C",i:[1,2,3,6,9,8]}); | |
db.recip.insert({_id:"D",i:[1,2,3]}); | |
A = [1,2,3,4]; | |
qry = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
convertAggregateResultToCollection (alias: carc) | |
Author: Ronald Stalder <[email protected]> | |
*/ | |
var convertAggregateResultToCollection = function (aggResult, options) { | |
// void function to supress output | |
var _v = function() {}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for mongo shell | |
// verify homework 3-1 without using aggregate (for Windows XP) | |
// "provide the identity of the student with the highest average in the class" | |
var maxAvg = 0; | |
var maxAvgId = 0; | |
// loop per student, calculate its' average and compare | |
var cursor = db.students.find(); | |
while ( cursor.hasNext() ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongodb = require('mongodb'); | |
var _ = require('underscore'); | |
var db = mongodb.Db('school', new mongodb.Server('localhost', 27017), {safe: true}); | |
db.open(function(err, client) { | |
if(err) { | |
console.log('Error opening connection' + err); | |
} | |
console.log('db opened'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongodb = require('mongodb'); | |
var _ = require('underscore'); | |
var db = mongodb.Db('students', new mongodb.Server('localhost', 27017), {safe: true}); | |
db.open(function(err, client) { | |
if(err) { | |
console.log('Error opening connection' + err); | |
} | |
console.log('db opened'); |