This week’s assignment requires creation of a table with reviews of five movies from friends and family in MySQL, read and analyzed in R. I chose children’s movies because with two little girls these are practically the only movies I have seen in the past four years. And I surveyed six friends and family who similarly are familiar with these animated features. I then used multiple analysis functions to display and analyze the data to see if any trends emerged.
library(RMySQL)
## Loading required package: DBI
mysqlconnection = dbConnect(MySQL(),user='root',password=password1,dbname='movies_db',host='localhost')
result = dbSendQuery(mysqlconnection,"select * from movie_reviews")
moviereview_df=fetch(result,n=6)
print(moviereview_df)
## Reviewer_ID Reviewer_Name Moana The_Incredibles Epic Lego_Movie Up
## 1 1 Christina 4 6 3 5 5
## 2 2 Vivian 5 4 4 4 5
## 3 3 James 4 4 3 3 4
## 4 4 Jill 5 4 3 1 5
## 5 5 Grandma 5 4 2 2 5
## 6 6 Grandpa 4 4 2 2 5
## Wall-E
## 1 5
## 2 3
## 3 4
## 4 5
## 5 3
## 6 3
averagescore <- colMeans(moviereview_df[,3:8])
print(averagescore)
## Moana The_Incredibles Epic Lego_Movie
## 4.500000 4.333333 2.833333 2.833333
## Up Wall-E
## 4.833333 3.833333