Shana Green

DATA 607 - Homework 2

Due Date: 9/05/2020

Introduction

For this assignment, I asked my friends and family to give me their input on six movies. This includes a sql file, in addition to the document.

Setup R and install packages

library(RMySQL)
## Loading required package: DBI

Connecting to MySQL

mydb = dbConnect(MySQL(), user='data607', password='data607!', dbname='moviesdb', host='localhost')

Run query to select data from database

movieData <-dbGetQuery(mydb,"SELECT m.title, c.user_name, r.review, r.rating FROM movies m
INNER JOIN reviews r
ON m.id = r.v_id
INNER JOIN critics c
ON r.c_id = c.user_id;")

Aggregate the data

aggregate(rating ~ title, data = movieData, FUN=mean)
##           title rating
## 1    21 Bridges   4.25
## 2 Black Panther   5.00
## 3         Joker   3.20
## 4  The Irishman   3.00
## 5 The Lion King   1.80
## 6   Toy Story 4   3.75