Part 3: Transfer data from SQL database to R dataframe

# Import the libraries
library(RMySQL)
library(DBI)
# Query the data
query <- "SELECT * FROM `puja.roy11`.mratings"
df <- dbGetQuery(con, query)
print(df)
##   id           movie_title person1 person2 person3 person4 person5
## 1  1               Titanic       4       5       5       3       2
## 2  2        Pretty in Pink       5       3       2       1       4
## 3  3 To Kill a Mockingbird       2       1       4       3       2
## 4  4          Pulp Fiction       3       5       3       4       5
## 5  5      The Great Gatsby       5       4       2       3       1
## 6  6           Bates Motel       3       4       2       5       1
# Close connection of the database
dbDisconnect(con)
## [1] TRUE

Part 4: Missing data strategy

To handle missing data, I can replace missing values with the mean or median of each column.