Data on film ratings were collected and saved as films.csv (https://raw.githubusercontent.com/sigmasigmaiota/films/master/films.csv), then stored in a SQL database. The data were then loaded into an R dataframe via RMySQL, DBI and tibble.
Table was composed using kableExtra.
library(RMySQL)
library(DBI)
library(tibble)
films.data=dbConnect(MySQL(),
user='root',
password=password_1,
dbname='films',
host='localhost')
knitr::opts_chunk$set(connection = "films.data")
ratings <- as_tibble(DBI::dbReadTable(films.data,"ratings"))
ratings.mean<-as.data.frame(sapply(ratings[2:7],mean))
colnames(ratings.mean)[1]<-"MeanScore"
library(kableExtra)
kable(ratings.mean,"html")%>%
kable_styling("striped",full_width = F)
| MeanScore | |
|---|---|
| Incredibles2 | 3.103448 |
| BlackPanther | 3.275862 |
| GetOut | 2.862069 |
| LadyBird | 2.275862 |
| Moonlight | 2.896552 |
| CallMebyYourName | 2.896552 |
In this sample, Black Panther was rated the highest.