This assignment presents the steps and the coding process taken from connecting to mySQL server to building a movie_ratings_tbl on mySQL Workbench and assigning it a new name, i.e., Films_ratings
Loading libraries
# | label: load - librarieslibrary(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.2 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.3 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(gt)
Name of the imported SQL data set
# |label: The original data set from SQL"Movies_ratings_tbl"
From mySQL Movies_ratings_tbl to Films_ratings in R:
Below is the gt version the mySQL Workbench data set:
library(gt)# Create a data frame with the specified column namesdata <-data.frame("Ticket to paradise"=numeric(5),"Canary"=numeric(5),"Office race"=numeric(5),"Amerikatsi"=numeric(5),"A Hunting in Venice"=numeric(5),"Kompromat"=numeric(5))# Add the rows with namesdata$Name <-c("David", "Richard", "Kelly", "Florence", "Max")# Reorder the columns to have 'Name' firstdata <- data[, c("Name", colnames(data)[1:6])]print(data)