Section: 11 Code Review: Exploratory Queries in R

11.1 Movies Dataset Example

11.1.1 Snippet 1: What is the mean imdb of low budget comedies?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxubWVhbihtb3ZpZXNbbW92aWVzJEJ1ZGdldD09J0xvdycgJiBtb3ZpZXMkZ2VucmU9PSdDb21lZHknLCBdJGltZGJfc2NvcmUpIn0=

11.1.2 Snippet 2: What is standard deviation of imdb score of high gross Family movies?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxuc2QobW92aWVzW21vdmllcyRHcm9zcz09J0hpZ2gnICYgbW92aWVzJGdlbnJlID09J0ZhbWlseScsXSRpbWRiKSJ9

11.1.3 Snippet 3: What is the lowest imdb score among high budget movies?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxubWluKG1vdmllc1ttb3ZpZXMkQnVkZ2V0PT0nSGlnaCcsXSRpbWRiKSJ9

11.1.4 Snippet 4: How many low budget movies generated high gross income?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxubnJvdyhtb3ZpZXNbbW92aWVzJEJ1ZGdldD09J0xvdycgJiBtb3ZpZXMkR3Jvc3MgPT0nSGlnaCcsXSkifQ==

11.1.5 Snippet 5: What is imdb score of the first non-US movie in the movies data frame?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxuI1lvdSBjYW4gdXNlIHRoaXMgc2ltcGxlIGNvbW1hbmQgdG8gcXVpY2tseSBmaW5kIG91dFxuaGVhZChtb3ZpZXNbbW92aWVzJGNvdW50cnkhPSdVU0EnLCBdJGltZGJfc2NvcmUpIn0=

11.1.6 Snippet 6: What is the least frequent genre among UK movies?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxuI1lvdSBjYW4gdXNlIHRoaXMgY29kZSB0byBmaW5kIG91dFxudGFibGUobW92aWVzW21vdmllcyRjb3VudHJ5PT0nVUsnLF0kZ2VucmUsIG1vdmllc1ttb3ZpZXMkY291bnRyeT09J1VLJyxdJGNvdW50cnkpIn0=

11.1.7 Snippet 7: Which content rating has the lowest average imdb score?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxuI1lvdSBjYW4gdXNlIHRoaXMgY29kZSB0byBmaW5kIG91dFxudGFwcGx5KG1vdmllcyRpbWRiLCBtb3ZpZXMkY29udGVudCwgbWVhbikifQ==

11.1.8 Snippet 8: Movies from which country have the smallest average imdb score?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxuI0JldHRlciBjb21wdXRlIGl0LCBzaW5jZSB0aGVyZSBhcmUgdG9vIG1hbnkgY291bnRyaWVzIGZvciB2aXN1YWwgaW5zcGVjdGlvblxuTUE8LWFnZ3JlZ2F0ZShtb3ZpZXMkaW1kYl9zY29yZSwgbGlzdChtb3ZpZXMkY291bnRyeSksIG1lYW4pXG5jb2xuYW1lcyhNQSk8LWMoXCJDb3VudHJ5XCIsIFwiTWltZGJcIilcbk1BPC1NQVtvcmRlcigtTUEkTWltZGIpLCBdXG5NQVsxLF0ifQ==

11.1.9 Snippet 9: What is the least frequent genre in movies data frame?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJtb3ZpZXM8LXJlYWQuY3N2KFwiaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2Rldjc3OTYvZGF0YTEwMV90dXRvcmlhbC9tYWluL2ZpbGVzL2RhdGFzZXQvTW92aWVzMjAyMkYtNC5jc3ZcIilcblxuejwtdGFibGUobW92aWVzJGdlbnJlKVxuc29ydCh6LGRlY3JlYXNpbmc9RkFMU0UpWzFdIn0=

11.1.10 Snippet 10: z value = 2.4, whats the p-value?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiIxLXBub3JtKDIuNCkifQ==

11.2 Census Dataset Example

11.2.1 Snippet 11: For the individual over 50, which profession has the highest average capital gain?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJjZW5zdXNfZGF0YTwtcmVhZC5jc3YoXCJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vZGV2Nzc5Ni9kYXRhMTAxX3R1dG9yaWFsL21haW4vZmlsZXMvZGF0YXNldC9DZW5zdXNEYXRhLmNzdlwiKVxuXG5hZ2VfZ3JlYXRlcl90aGFuXzQ5ID0gc3Vic2V0KGNlbnN1c19kYXRhLCBjZW5zdXNfZGF0YSRBR0UgPj0gNTApXG5hZ2VkX2NhcGl0YWxnYWlucyA9IHRhcHBseShhZ2VfZ3JlYXRlcl90aGFuXzQ5JENBUElUQUxHQUlOUywgYWdlX2dyZWF0ZXJfdGhhbl80OSRQUk9GRVNTSU9OLCBtZWFuKVxuYWdlZF9jYXBpdGFsZ2FpbnMifQ==

11.2.2 Snippet 12: Which profession has the highest average capital gains; Sales or Tech-support?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJjZW5zdXNfZGF0YTwtcmVhZC5jc3YoXCJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vZGV2Nzc5Ni9kYXRhMTAxX3R1dG9yaWFsL21haW4vZmlsZXMvZGF0YXNldC9DZW5zdXNEYXRhLmNzdlwiKVxuXG5leGFtcGxlMTJfZGF0YSA9IHRhcHBseShjZW5zdXNfZGF0YSRDQVBJVEFMR0FJTiwgY2Vuc3VzX2RhdGEkUFJPRkVTU0lPTiwgbWVhbilcbmV4YW1wbGUxMl9kYXRhIn0=

11.2.3 Snippet 13: What is most frequent profession of people with less than 10 years od of education?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJjZW5zdXNfZGF0YTwtcmVhZC5jc3YoXCJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vZGV2Nzc5Ni9kYXRhMTAxX3R1dG9yaWFsL21haW4vZmlsZXMvZGF0YXNldC9DZW5zdXNEYXRhLmNzdlwiKVxuXG5leGFtcGxlMTNfZGF0YSA9IHRhYmxlKHN1YnNldChjZW5zdXNfZGF0YSwgWUVBUlMgPD0gMTApJFBST0ZFU1NJT04pXG5leGFtcGxlMTNfZGF0YSJ9

11.2.4 Snippet 14: What is minimum number of years of education for people with Exec-managerial specialty?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJjZW5zdXNfZGF0YTwtcmVhZC5jc3YoXCJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vZGV2Nzc5Ni9kYXRhMTAxX3R1dG9yaWFsL21haW4vZmlsZXMvZGF0YXNldC9DZW5zdXNEYXRhLmNzdlwiKVxuXG5leGFtcGxlMTRfZGF0YSA9IG1pbihzdWJzZXQoY2Vuc3VzX2RhdGEsIFBST0ZFU1NJT04gPT0gXCJFeGVjLW1hbmFnZXJpYWxcIikkWUVBUlMpXG5leGFtcGxlMTRfZGF0YSJ9

11.2.5 Snippet 15: What is the most frequent degree for natives of the United States?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJjZW5zdXNfZGF0YTwtcmVhZC5jc3YoXCJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vZGV2Nzc5Ni9kYXRhMTAxX3R1dG9yaWFsL21haW4vZmlsZXMvZGF0YXNldC9DZW5zdXNEYXRhLmNzdlwiKVxuXG5leGFtcGxlMTVfZGF0YSA9IHRhYmxlKHN1YnNldChjZW5zdXNfZGF0YSwgTkFUSVZFID09IFwiVW5pdGVkLVN0YXRlc1wiKSRFRFVDQVRJT04pXG5leGFtcGxlMTVfZGF0YSJ9

11.2.6 Snippet 16: What is the least frequent degree for people with at least 12 years of education?

eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiJjZW5zdXNfZGF0YTwtcmVhZC5jc3YoXCJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vZGV2Nzc5Ni9kYXRhMTAxX3R1dG9yaWFsL21haW4vZmlsZXMvZGF0YXNldC9DZW5zdXNEYXRhLmNzdlwiKVxuXG5leGFtcGxlMTZfZGF0YSA9IHRhYmxlKHN1YnNldChjZW5zdXNfZGF0YSwgWUVBUlMgPj0gMTIpJEVEVUNBVElPTilcbmV4YW1wbGUxNl9kYXRhIn0=