library(tictoc)
tic()
<- rnorm(1000000)
rand_numbers quantile(rand_numbers)
0% 25% 50% 75% 100%
-4.7441954424 -0.6750814407 0.0006767307 0.6734974364 5.6445201338
toc()
0.097 sec elapsed
your name goes here
January 8, 2024
Today’s lab will provide practice working with the different tools we can use to implement SQL code. We haven’t covered much SQL syntax, so the focus will be more on the tools than on writing code. You should, however, be trying to understand the SQL code as you go along.
The goals for lab 1 include:
render early and often. In fact, go ahead and render your .qmd file right now. Maybe set a timer so that you render every 5 minutes. Do not wait until you are done with the assignment to render
save the .Rproj file somewhere you can find it. Don’t keep everything in your downloads folder. Maybe make a folder called SDS261
or something. That folder could live on your Desktop. Or maybe in your Dropbox.
Preliminary: You’ll need to create a quarto document. To do so click on: New file -> quarto document.
lab1-sds261-yourlastname-yourfirstname.qmd
.---
title: 'Lab 1 - working with Databases'
author: 'your name goes here'
date: 'due 10am Tuesday, January 9, 2024'
execute:
echo: true
warning: false
message: false
---
For much of the assignment, Consider the task of figuring out how many flights came into or flew out of Bradley International Airport (BDL) last year.
flights
table as a tbl
(do not use collect()
!). Use dplyr commands to calculate the number of flights that flew into or out of BDL in 2012. Then use dplyr::show_query()
to output the SQL query. (All done inside an R chunk.)DBI::dbGetQuery()
to run the SQL code calculated in the previous question.tic()
in an R chunk before the SQL chunk and toc()
in an R chunk after the SQL chunk. Write 1-2 sentences describing the results. 0% 25% 50% 75% 100%
-4.7441954424 -0.6750814407 0.0006767307 0.6734974364 5.6445201338
0.097 sec elapsed
tbl
.dbGetQuery()
.tibble
(not a tbl
) that includes only flights in 2012 either to or from BDL (use collect()
). After you have created the tibble
, summarize the observations to get the count. Use tictoc to evaluate how long the process takes. Write 1-2 sentences describing the results.lab1-sds261-yourlastname-yourfirstname.sql
and SAVE THE FILE in the lab1 R Project folder. Run the same SQL code as above. Did you get the same result? Were there any adjustments to the SQL code from above? Explain in a few sentences.