From ca389985ace3789cc46acd464d8d7a475530d0a9 Mon Sep 17 00:00:00 2001 From: Haoyu Yu Date: Wed, 6 Nov 2024 13:02:38 -0800 Subject: [PATCH] Lab10 https://github.com/USCbiostats/PM566/issues/86 --- Lab10.html | 33 +++++++++++++++------------------ Lab10.qmd | 3 --- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Lab10.html b/Lab10.html index 5d0f5b1..e0c158f 100644 --- a/Lab10.html +++ b/Lab10.html @@ -3103,24 +3103,21 @@

Lab10

Setup

# install.packages(c("RSQLite", "DBI"))
-
-library(RSQLite)
-library(DBI)
-
-# Initialize a temporary in memory database
-con <- dbConnect(SQLite(), ":memory:")
-
-# Download tables
-actor <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/actor.csv")
-rental <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/rental.csv")
-customer <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/customer.csv")
-payment <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/payment_p2007_01.csv")
-
-# Copy data.frames to database
-dbWriteTable(con, "actor", actor)
-dbWriteTable(con, "rental", rental)
-dbWriteTable(con, "customer", customer)
-dbWriteTable(con, "payment", payment)
+library(RSQLite) +library(DBI) +# Initialize a temporary in memory database +con <- dbConnect(SQLite(), ":memory:") +# Download tables +actor <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/actor.csv") +rental <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/rental.csv") +customer <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/customer.csv") +payment <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/payment_p2007_01.csv") + +# Copy data.frames to database +dbWriteTable(con, "actor", actor) +dbWriteTable(con, "rental", rental) +dbWriteTable(con, "customer", customer) +dbWriteTable(con, "payment", payment)
dbListTables(con)
diff --git a/Lab10.qmd b/Lab10.qmd index 7f90437..c57e924 100644 --- a/Lab10.qmd +++ b/Lab10.qmd @@ -8,13 +8,10 @@ embed-resources: true # Setup ```{r} # install.packages(c("RSQLite", "DBI")) - library(RSQLite) library(DBI) - # Initialize a temporary in memory database con <- dbConnect(SQLite(), ":memory:") - # Download tables actor <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/actor.csv") rental <- read.csv("https://raw.githubusercontent.com/ivanceras/sakila/master/csv-sakila-db/rental.csv")