## Loading required package: DBI
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::ident() masks dbplyr::ident()
## ✖ dplyr::lag() masks stats::lag()
## ✖ dplyr::sql() masks dbplyr::sql()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library("RMySQL")
library(DBI)
library(dbplyr)
library(tidyverse)
library(knitr)
# #sql <- "CREATE TABLE MovieReview (
# movieID int AUTO_INCREMENT PRIMARY KEY,
# movieName varchar(255),
# reviewName varchar(255),
# movieRating int)"
sql <- "TRUNCATE TABLE MovieReview;";
dbGetQuery(conn, sql);
data frame with 0 columns and 0 rows
sql <- "SELECT *
FROM MovieReview";
#View(dbGetQuery(conn, sql))
kable(dbGetQuery(conn, sql))
| movieID | movieName | reviewName | movieRating |
|---|
sql <- "INSERT INTO MovieReview (movieName, reviewName, movieRating)
VALUES ('Avengers: Age of Ultron', 'Alex', 4);";
dbGetQuery(conn, sql);
data frame with 0 columns and 0 rows
sql <- "INSERT INTO MovieReview (movieName, reviewName, movieRating)
VALUES ('MacBeth', 'Tiana', 4);";
dbGetQuery(conn, sql);
data frame with 0 columns and 0 rows
sql <- "INSERT INTO MovieReview (movieName, reviewName, movieRating)
VALUES ('Wall-E', 'Atta', 5);";
dbGetQuery(conn, sql);
data frame with 0 columns and 0 rows
sql <- "INSERT INTO MovieReview (movieName, reviewName, movieRating)
VALUES ('Color Purple', 'Ophelia', 4);";
dbGetQuery(conn, sql);
data frame with 0 columns and 0 rows
sql <- "INSERT INTO MovieReview (movieName, reviewName, movieRating)
VALUES ('Terminator', 'Ebenezer', 3);";
dbGetQuery(conn, sql);
data frame with 0 columns and 0 rows
sql <- "INSERT INTO MovieReview (movieName, reviewName, movieRating)
VALUES ('Friday', 'Kobe', 4);";
dbGetQuery(conn, sql);
data frame with 0 columns and 0 rows
sql <- "SELECT *
FROM MovieReview";
data <- data.frame(dbGetQuery(conn, sql));
kable(data)
| movieID | movieName | reviewName | movieRating |
|---|---|---|---|
| 1 | Avengers: Age of Ultron | Alex | 4 |
| 2 | MacBeth | Tiana | 4 |
| 3 | Wall-E | Atta | 5 |
| 4 | Color Purple | Ophelia | 4 |
| 5 | Terminator | Ebenezer | 3 |
| 6 | Friday | Kobe | 4 |
I would remove rows with missing data because I would not want to obscure the data set. For example, if I wanted to find the average ratings of movies of the same title, row in which the data is missing might give an inaccurate depiction of the ratings.