├── README.md ├── .gitignore ├── img ├── author_image.png └── shield_image.png ├── datasets ├── all-files.zip ├── lab8_wk.RData ├── present_ex5.RData ├── present_ex6.RData ├── present_ex7.RData ├── rdu_flights.RData ├── ch2_ex1 │ ├── .init.R │ ├── .Rprofile │ ├── lab.css │ └── lab2_ex1.Rmd ├── ch2_ex10 │ ├── .init.R │ ├── .Rprofile │ ├── lab2_ex10.Rmd │ └── lab.css ├── ch2_ex4 │ ├── .init.R │ ├── .Rprofile │ ├── lab2_ex4.Rmd │ └── lab.css ├── ch2_ex5 │ ├── .init.R │ ├── .Rprofile │ ├── lab2_ex5.Rmd │ └── lab.css ├── ch2_ex6 │ ├── .init.R │ ├── .Rprofile │ ├── lab2_ex6.Rmd │ └── lab.css ├── ch2_ex7 │ ├── .init.R │ ├── .Rprofile │ ├── lab2_ex7.Rmd │ └── lab.css ├── ch2_ex8 │ ├── .init.R │ ├── .Rprofile │ ├── lab2_ex8.Rmd │ └── lab.css ├── ch3_ex1 │ ├── .init.R │ ├── .Rprofile │ ├── lab3_ex1.Rmd │ └── lab.css ├── ch3_ex2 │ ├── .init.R │ ├── .Rprofile │ ├── lab3_ex2.Rmd │ └── lab.css ├── ch3_ex3 │ ├── .init.R │ ├── .Rprofile │ ├── lab3_ex3.Rmd │ └── lab.css ├── ch3_ex4 │ ├── .init.R │ ├── .Rprofile │ ├── lab.css │ └── lab3_ex4.Rmd ├── ch3_ex5 │ ├── .init.R │ ├── .Rprofile │ ├── lab3_ex5.Rmd │ └── lab.css ├── ch1_ex1 │ ├── .init.R │ ├── .Rprofile │ ├── lab.css │ └── lab1_ex1.Rmd ├── ch1_ex5 │ ├── .init.R │ ├── .Rprofile │ ├── lab1_ex5.Rmd │ └── lab.css ├── ch1_ex8 │ ├── lab8_wk.RData │ ├── .init.R │ ├── .Rprofile │ ├── lab1_ex8.Rmd │ └── lab.css ├── ch1_ex2 │ ├── .init.R │ ├── .Rprofile │ ├── lab1_ex2.Rmd │ └── lab.css ├── ch1_ex3 │ ├── .init.R │ ├── .Rprofile │ ├── lab.css │ └── lab1_ex3.Rmd ├── ch1_ex4 │ ├── .init.R │ ├── .Rprofile │ ├── lab1_ex4.Rmd │ └── lab.css ├── ch2_ex3 │ ├── rdu_flights.RData │ ├── .Rprofile │ ├── .init.R │ ├── lab2_ex3.Rmd │ └── lab.css ├── ch1_ex6 │ ├── .init.R │ ├── .Rprofile │ ├── lab1_ex6.Rmd │ └── lab.css ├── ch2_ex9 │ ├── .init.R │ ├── .Rprofile │ ├── lab2_ex9.Rmd │ └── lab.css ├── ch1_ex7 │ ├── .init.R │ ├── .Rprofile │ ├── lab1_ex7.Rmd │ └── lab.css ├── ch2_ex2 │ ├── .Rprofile │ ├── .init.R │ ├── lab2_ex2.Rmd │ └── lab.css ├── lab.css └── ch3_key.Rmd ├── requirements.r ├── requirements.sh ├── course.yml ├── chapter3.Rmd └── chapter1.Rmd /README.md: -------------------------------------------------------------------------------- 1 | # Statistical Thinking with R 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user/* 2 | .Rproj.user 3 | .cache 4 | .DS_STORE 5 | .Rhistory 6 | .RData 7 | .Rdata 8 | .rdata 9 | -------------------------------------------------------------------------------- /img/author_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/img/author_image.png -------------------------------------------------------------------------------- /img/shield_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/img/shield_image.png -------------------------------------------------------------------------------- /datasets/all-files.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/datasets/all-files.zip -------------------------------------------------------------------------------- /datasets/lab8_wk.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/datasets/lab8_wk.RData -------------------------------------------------------------------------------- /datasets/present_ex5.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/datasets/present_ex5.RData -------------------------------------------------------------------------------- /datasets/present_ex6.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/datasets/present_ex6.RData -------------------------------------------------------------------------------- /datasets/present_ex7.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/datasets/present_ex7.RData -------------------------------------------------------------------------------- /datasets/rdu_flights.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/datasets/rdu_flights.RData -------------------------------------------------------------------------------- /datasets/ch2_ex1/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex1.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch2_ex10/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex10.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch2_ex4/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex4.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch2_ex5/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex5.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch2_ex6/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex6.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch2_ex7/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex7.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch2_ex8/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex8.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch3_ex1/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab3_ex1.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch3_ex2/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab3_ex2.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch3_ex3/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab3_ex3.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch3_ex4/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab3_ex4.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch3_ex5/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab3_ex5.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) -------------------------------------------------------------------------------- /datasets/ch1_ex1/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab1_ex1.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | -------------------------------------------------------------------------------- /datasets/ch1_ex5/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab1_ex5.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | -------------------------------------------------------------------------------- /datasets/ch1_ex8/lab8_wk.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/datasets/ch1_ex8/lab8_wk.RData -------------------------------------------------------------------------------- /datasets/ch1_ex2/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab1_ex2.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | 9 | -------------------------------------------------------------------------------- /datasets/ch1_ex3/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab1_ex3.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | 9 | -------------------------------------------------------------------------------- /datasets/ch1_ex4/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab1_ex4.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | 9 | -------------------------------------------------------------------------------- /datasets/ch2_ex3/rdu_flights.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacamp/community-courses-introduction-to-probability-and-data-labs/master/datasets/ch2_ex3/rdu_flights.RData -------------------------------------------------------------------------------- /requirements.r: -------------------------------------------------------------------------------- 1 | library(remotes) 2 | # Use last mvtnorm that allowed R 3.4 3 | install_github("cran/mvtnorm", ref = "39daaf201178042e8c1adde29565d96e5424e21a") 4 | install_version("statsr", "0.1-0", dependencies = TRUE, upgrade = TRUE) 5 | -------------------------------------------------------------------------------- /datasets/ch1_ex6/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab1_ex6.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | load(url("https://assets.datacamp.com/production/repositories/302/datasets/60880e9ce4174b0c05266a5ef847b407dadf4bed/present_ex5.RData")) 9 | -------------------------------------------------------------------------------- /datasets/ch1_ex8/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab1_ex8.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | load(url("https://assets.datacamp.com/production/repositories/302/datasets/68df966c56e035687f26596ca3d7e1a8e6f9dfe4/present_ex7.RData")) 9 | -------------------------------------------------------------------------------- /datasets/ch2_ex9/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex9.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | 9 | 10 | # Updating the dataset nycflights from exercise 8 11 | nycflights <- nycflights %>% 12 | mutate(avg_speed = distance / (air_time/60)) 13 | -------------------------------------------------------------------------------- /datasets/ch1_ex7/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab1_ex7.2.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | load(url("https://assets.datacamp.com/production/repositories/302/datasets/aa20c57e6278b2e1c887165548914e4c7630d62a/present_ex6.RData")) 9 | 10 | # Knit Rmd file 11 | #rmarkdown::render("lab1_ex7.2.Rmd") 12 | -------------------------------------------------------------------------------- /requirements.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # get zip of all files 5 | wget https://assets.datacamp.com/production/repositories/302/datasets/b9177982f038025ad55127ebcd2f91c26f201afa/all-files.zip 6 | 7 | # unzip all files 8 | unzip all-files.zip -d $DATADIR/ 9 | 10 | # install some other requirements 11 | apt-get update && apt-get --yes --force-yes install libxml2-dev libcairo2-dev libgdal-dev -------------------------------------------------------------------------------- /course.yml: -------------------------------------------------------------------------------- 1 | title: Introduction to Probability and Data - Labs 2 | description: This interactive DataCamp course complements the Coursera course 3 | Introduction to Probability and Data by Mine Çetinkaya-Rundel. For 4 | every lesson given at Coursera, you can follow interactive exercises in the 5 | comfort of your browser to master the different topics. 6 | programming_language: r 7 | from: 'r-rstudio-prod:v1.1.0' 8 | -------------------------------------------------------------------------------- /datasets/ch1_ex1/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab1_ex1.Rmd") 7 | rmarkdown::render("lab1_ex1.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab1_ex1.html", file.path(tempdir(), "lab1_ex1.html")) 10 | myViewer(file.path(tempdir(), "lab1_ex1.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch1_ex3/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab1_ex3.Rmd") 7 | rmarkdown::render("lab1_ex3.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab1_ex3.html", file.path(tempdir(), "lab1_ex3.html")) 10 | myViewer(file.path(tempdir(), "lab1_ex3.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch1_ex4/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab1_ex4.Rmd") 7 | rmarkdown::render("lab1_ex4.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab1_ex4.html", file.path(tempdir(), "lab1_ex4.html")) 10 | myViewer(file.path(tempdir(), "lab1_ex4.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch1_ex6/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab1_ex6.Rmd") 7 | rmarkdown::render("lab1_ex6.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab1_ex6.html", file.path(tempdir(), "lab1_ex6.html")) 10 | myViewer(file.path(tempdir(), "lab1_ex6.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch1_ex7/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab1_ex7.Rmd") 7 | rmarkdown::render("lab1_ex7.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab1_ex7.html", file.path(tempdir(), "lab1_ex7.html")) 10 | myViewer(file.path(tempdir(), "lab1_ex7.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex1/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex1.Rmd") 7 | rmarkdown::render("lab2_ex1.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex1.html", file.path(tempdir(), "lab2_ex1.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex1.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex2/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex2.Rmd") 7 | rmarkdown::render("lab2_ex2.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex2.html", file.path(tempdir(), "lab2_ex2.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex2.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex3/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex3.Rmd") 7 | rmarkdown::render("lab2_ex3.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex3.html", file.path(tempdir(), "lab2_ex3.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex3.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex4/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex4.Rmd") 7 | rmarkdown::render("lab2_ex4.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex4.html", file.path(tempdir(), "lab2_ex4.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex4.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex5/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex5.Rmd") 7 | rmarkdown::render("lab2_ex5.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex5.html", file.path(tempdir(), "lab2_ex5.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex5.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex6/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex6.Rmd") 7 | rmarkdown::render("lab2_ex6.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex6.html", file.path(tempdir(), "lab2_ex6.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex6.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex7/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex7.Rmd") 7 | rmarkdown::render("lab2_ex7.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex7.html", file.path(tempdir(), "lab2_ex7.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex7.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex8/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex8.Rmd") 7 | rmarkdown::render("lab2_ex8.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex8.html", file.path(tempdir(), "lab2_ex8.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex8.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch2_ex9/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex9.Rmd") 7 | rmarkdown::render("lab2_ex9.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex9.html", file.path(tempdir(), "lab2_ex9.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex9.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch3_ex1/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab3_ex1.Rmd") 7 | rmarkdown::render("lab3_ex1.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab3_ex1.html", file.path(tempdir(), "lab3_ex1.html")) 10 | myViewer(file.path(tempdir(), "lab3_ex1.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch3_ex2/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab3_ex2.Rmd") 7 | rmarkdown::render("lab3_ex2.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab3_ex2.html", file.path(tempdir(), "lab3_ex2.html")) 10 | myViewer(file.path(tempdir(), "lab3_ex2.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch3_ex3/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab3_ex3.Rmd") 7 | rmarkdown::render("lab3_ex3.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab3_ex3.html", file.path(tempdir(), "lab3_ex3.html")) 10 | myViewer(file.path(tempdir(), "lab3_ex3.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch3_ex4/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab3_ex4.Rmd") 7 | rmarkdown::render("lab3_ex4.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab3_ex4.html", file.path(tempdir(), "lab3_ex4.html")) 10 | myViewer(file.path(tempdir(), "lab3_ex4.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch3_ex5/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab3_ex5.Rmd") 7 | rmarkdown::render("lab3_ex5.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab3_ex5.html", file.path(tempdir(), "lab3_ex5.html")) 10 | myViewer(file.path(tempdir(), "lab3_ex5.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch1_ex2/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab1_ex2.Rmd") 7 | rmarkdown::render("lab1_ex2.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab1_ex2.html", file.path(tempdir(), "lab1_ex2.html")) 10 | myViewer(file.path(tempdir(), "lab1_ex2.html")) 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /datasets/ch1_ex5/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab1_ex5.Rmd") 7 | rmarkdown::render("lab1_ex5.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab1_ex5.html", file.path(tempdir(), "lab1_ex5.html")) 10 | myViewer(file.path(tempdir(), "lab1_ex5.html")) 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /datasets/ch2_ex10/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab2_ex10.Rmd") 7 | rmarkdown::render("lab2_ex10.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab2_ex10.html", file.path(tempdir(), "lab2_ex10.html")) 10 | myViewer(file.path(tempdir(), "lab2_ex10.html")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /datasets/ch1_ex8/.Rprofile: -------------------------------------------------------------------------------- 1 | .First <- function() { 2 | message("Type go() and hit Enter to get started!\n") 3 | 4 | go <<- function() { 5 | source(".init.R") 6 | file.edit("lab1_ex8.Rmd") 7 | rmarkdown::render("lab1_ex8.Rmd") 8 | myViewer <- getOption("viewer") 9 | file.copy("lab1_ex8.html", file.path(tempdir(), "lab1_ex8.html")) 10 | myViewer(file.path(tempdir(), "lab1_ex8.html")) 11 | load("lab8_wk.RData") 12 | } 13 | } 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /datasets/ch2_ex2/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex2.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | 9 | # The following code is from exercise 1 to create the rdu_flights data frame 10 | rdu_flights <- nycflights %>% 11 | filter(dest == "RDU") 12 | 13 | # The following code is from exercise 1 to create the sfo_feb_flights data frame 14 | sfo_feb_flights <- nycflights %>% 15 | filter(dest == "SFO", month == 2) 16 | -------------------------------------------------------------------------------- /datasets/ch2_ex3/.init.R: -------------------------------------------------------------------------------- 1 | # open file in editor 2 | file.edit("lab2_ex3.Rmd") 3 | 4 | # load packages 5 | library(dplyr) 6 | library(ggplot2) 7 | library(statsr) 8 | 9 | # The following code is from exercise 1 to create the rdu_flights data frame 10 | rdu_flights <- nycflights %>% 11 | filter(dest == "RDU") 12 | 13 | # The following code is from exercise 1 to create the sfo_feb_flights data frame 14 | sfo_feb_flights <- nycflights %>% 15 | filter(dest == "SFO", month == 2) 16 | -------------------------------------------------------------------------------- /datasets/ch3_ex2/lab3_ex2.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Probability" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | Again, in Game 1 Kobe had the following sequence of hits and misses from 11 | his nine shot attempts in the first quarter: 12 | 13 | \[ \textrm{H M | M | H H M | M | M | M} \] 14 | 15 | You can verify this by viewing the first 8 rows of the data in the data viewer. 16 | 17 | Within the nine shot attempts, there are six streaks, which are separated by a 18 | "|" above. Their lengths are one, zero, two, zero, zero, zero (in order of 19 | occurrence). 20 | 21 | 2. Fill in the blank: A streak length of 0 means one \_\_\_ which must occur after a 22 | miss that ended the preceeding streak. 23 | Answer Question 2 to the left. 24 | 25 | -------------------------------------------------------------------------------- /datasets/ch2_ex9/lab2_ex9.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 9. Make a scatterplot of `avg_speed` vs. `distance`. Which of the following is true 11 | about the relationship between average speed and distance. 12 | Answer Question 9 to the left. 13 | 14 | ```{r load-packages, message = FALSE, echo = FALSE} 15 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 16 | library(statsr) 17 | library(dplyr) 18 | library(ggplot2) 19 | 20 | nycflights <- nycflights %>% 21 | mutate(avg_speed = distance / (air_time/60)) 22 | 23 | ``` 24 | 25 | 26 | ```{r avg-speed-dist-scatter} 27 | # type your code for Question 9 here, and Knit 28 | 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /datasets/ch1_ex6/lab1_ex6.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to R and RStudio" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 6. Create a new variable called `more_boys` which contains the value of either `TRUE` if that year had more boys than girls, or `FALSE` if that year did not. Based on this variable which of the following statements is true? Answer Question 6 to the left. 11 | 12 | The code that created the `more_boys` column for the `arbuthnot` dataset used the following functions and operators: `%>%`, `mutate()`, `>`. 13 | 14 | ```{r load-packages, message = FALSE, echo = FALSE} 15 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 16 | library(dplyr) 17 | library(statsr) 18 | library(ggplot2) 19 | data(present) 20 | ``` 21 | 22 | 23 | ```{r more-boys-per-year} 24 | # type your code for Question 6 here, use the output from this line to answer Question 6, and Knit 25 | 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /datasets/ch3_ex3/lab3_ex3.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Probability" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | Counting streak lengths manually for all 133 shots would get tedious, so we'll 10 | use the custom function `calc_streak` to calculate them, and store the results 11 | in a data frame called `kobe_streak` as the `length` variable. 12 | 13 | ```{r load-packages, message = FALSE, echo = FALSE} 14 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 15 | library(statsr) 16 | library(dplyr) 17 | library(ggplot2) 18 | ``` 19 | 20 | ```{r calc-streak-kobe} 21 | kobe_streak <- calc_streak(kobe_basket$shot) 22 | ``` 23 | 24 | We can then take a look at the distribution of these streak lengths. 25 | 26 | ```{r plot-streak-kobe} 27 | ggplot(data = kobe_streak, aes(x = length)) + 28 | geom_histogram(binwidth = 1) 29 | ``` 30 | 31 | 3. Which of the following is false about the distribution of Kobe's streak lengths 32 | from the 2009 NBA finals. 33 | Answer Question 3 to the left. 34 | 35 | -------------------------------------------------------------------------------- /datasets/ch1_ex7/lab1_ex7.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to R and RStudio" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 11 | 7. Calculate the boy-to-girl ratio each year, and store these values in a new variable called `prop_boy_girl` in the `present` dataset. Plot these values over time. Which of the following best describes the trend? Answer Question 7 to the left. 12 | 13 | In case you forgot, you can add variables to a dataset using the `$` operator. (i.e. `dataset$new_column <- dataset$column1 -+ dataset$column2`) 14 | 15 | You used the following code to plot the proportion of boy births over time for the `arbuthnot` dataset. 16 | `ggplot(data = arbuthnot, aes(x = year, y = boys/total)) + geom_line() + geom_point()` 17 | 18 | 19 | ```{r load-packages, message = FALSE, echo=FALSE} 20 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 21 | library(dplyr) 22 | library(statsr) 23 | library(ggplot2) 24 | ``` 25 | 26 | 27 | ```{r prop-boy-girl-over-time} 28 | # type your code for Question 7 here, use the output from this line to answer Question 7, and Knit 29 | 30 | ``` 31 | -------------------------------------------------------------------------------- /datasets/ch2_ex8/lab2_ex8.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 8. Mutate the data frame so that it includes a new variable that contains the 11 | average speed, `avg_speed` traveled by the plane for each flight (in mph). What is 12 | the tail number of the plane with the fastest `avg_speed`? **Hint:** Average speed 13 | can be calculated as distance divided by number of hours of travel, and note that 14 | `air_time` is given in minutes. If you just want to show the `avg_speed` and 15 | `tailnum` and none of the other variables, use the select function at the end of your 16 | pipe to select just these two variables with `select(avg_speed, tailnum)`. You can 17 | Google this tail number to find out more about the aircraft. 18 | Answer Question 8 to the left. 19 | 20 | ```{r load-packages, message = FALSE, echo = FALSE} 21 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 22 | library(statsr) 23 | library(dplyr) 24 | library(ggplot2) 25 | ``` 26 | 27 | 28 | ```{r fastest-avg-speed-tailnum} 29 | # type your code for Question 8 here, and Knit 30 | 31 | ``` 32 | -------------------------------------------------------------------------------- /datasets/ch2_ex5/lab2_ex5.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 5. Which month has the highest median departure delay from an NYC airport? 11 | Answer Question 5 to the left. 12 | 13 | Let's think about how we would answer this question: 14 | 15 | - In the previous exercise, the monthly averages for departure delays were calculated. For this exercise, we need to 16 | + `group_by` months, then 17 | + `summarise` median departure delays. 18 | - Then, we need to `arrange` these average delays in `desc`ending order 19 | 20 | ```{r load-packages, message = FALSE, echo = FALSE} 21 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 22 | library(statsr) 23 | library(dplyr) 24 | library(ggplot2) 25 | ``` 26 | 27 | ```{r mean-dep-delay-months} 28 | # Here is the code from the previous exercise to find the mean departure delay per month 29 | nycflights %>% 30 | group_by(month) %>% 31 | summarise(mean_dd = mean(dep_delay)) %>% 32 | arrange(desc(mean_dd)) 33 | ``` 34 | 35 | ```{r highest-median-dep-delay-month} 36 | # type your code for Question 5 here, and Knit 37 | 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /datasets/ch2_ex6/lab2_ex6.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 6. Is the mean or the median a more reliable measure for deciding which month(s) to 11 | avoid flying if you really dislike delayed flights, and why? 12 | Answer Question 6 to the left. 13 | 14 | 15 | We can also visualize the distributions of departure delays across months using 16 | side-by-side box plots: 17 | 18 | ```{r load-packages, message = FALSE, echo = FALSE} 19 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 20 | library(statsr) 21 | library(dplyr) 22 | library(ggplot2) 23 | ``` 24 | 25 | 26 | ```{r delay-month-box} 27 | ggplot(nycflights, aes(x = factor(month), y = dep_delay)) + 28 | geom_boxplot() 29 | ``` 30 | 31 | There is some new syntax here: We want departure delays on the y-axis and the 32 | months on the x-axis to produce side-by-side box plots. Side-by-side box plots 33 | require a categorical variable on the x-axis, however in the data frame `month` is 34 | stored as a numerical variable (numbers 1 - 12). Therefore we can force R to treat 35 | this variable as categorical, what R calls a **factor**, variable with 36 | `factor(month)`. 37 | 38 | -------------------------------------------------------------------------------- /datasets/ch2_ex4/lab2_ex4.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | ### Departure delays over months 11 | 12 | Which month would you expect to have the highest average delay departing 13 | from an NYC airport? 14 | 15 | Let's think about how we would answer this question: 16 | 17 | - First, calculate monthly averages for departure delays. With the new language 18 | we are learning, we need to 19 | + `group_by` months, then 20 | + `summarise` mean departure delays. 21 | - Then, we need to `arrange` these average delays in `desc`ending order 22 | 23 | ```{r load-packages, message = FALSE, echo = FALSE} 24 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 25 | library(statsr) 26 | library(dplyr) 27 | library(ggplot2) 28 | ``` 29 | 30 | 31 | ```{r mean-dep-delay-months} 32 | nycflights %>% 33 | group_by(month) %>% 34 | summarise(mean_dd = mean(dep_delay)) %>% 35 | arrange(desc(mean_dd)) 36 | ``` 37 | 38 | 4. Which month has the highest average departure delay from an NYC airport? 39 | Answer Question 4 to the left. 40 | 41 | ```{r highest-avg-dep-delay-month} 42 | # type your code for Question 4 here, and Knit 43 | 44 | ``` 45 | 46 | -------------------------------------------------------------------------------- /datasets/ch2_ex10/lab2_ex10.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 10. Suppose you define a flight to be "on time" if it gets to the destination on time or earlier than expected, regardless of any departure delays. Mutate the data frame to create a new variable called `arr_type` with levels `"on time"` and `"delayed"` based on this definition. Also mutate to create a new variable called `dep_type` with levels `"on time"` and `"delayed"` depending on the flight was delayed for fewer than 5 minutes or 5 minutes or more, respectively. In other words, if `arr_delay` is 0 minutes or fewer, `arr_type` is `"on time"`. If `dep_delay` is less than 5 minutes, `dep_type` is `"on time"`. Then, determine the on time arrival percentage based on whether the flight departed on time or not. What percent of flights that were `"delayed"` departing arrive `"on time"`? 11 | Answer Question 10 to the left. 12 | 13 | ```{r load-packages, message = FALSE, echo = FALSE} 14 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 15 | library(statsr) 16 | library(dplyr) 17 | library(ggplot2) 18 | ``` 19 | 20 | 21 | ```{r on-time-arr-perc} 22 | # type your code for Question 10 here, and Knit 23 | 24 | ``` 25 | -------------------------------------------------------------------------------- /datasets/ch1_ex4/lab1_ex4.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to R and RStudio" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | ## Dataset 2: Present birth records 11 | 12 | In the previous few pages, you recreated some of the displays and preliminary analysis of Arbuthnot's baptism data. Next you will do a similar analysis, but for present day birth records in the United States. Load up the present day data with the following command. 13 | 14 | ```{r load-packages, message = FALSE, echo = FALSE} 15 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 16 | library(dplyr) 17 | library(statsr) 18 | library(ggplot2) 19 | ``` 20 | 21 | ```{r load-present-data} 22 | data(present) 23 | ``` 24 | 25 | The data are stored in a data frame called `present` which should now be loaded in your workspace. 26 | 27 | 4. How many variables are included in this data set? Answer Question 4 to the left. 28 | 29 | ```{r variables-in-present} 30 | # type your code for Question 4 here, use the output from this line to answer Question 4, and Knit 31 | 32 | ``` 33 | 34 |
35 | **Exercise**: What years are included in this dataset? **Hint:** Use the `range` function and `present$year` as its argument. 36 |
37 | 38 | ```{r years-in-present-data} 39 | # type your code for Exercise here, and Knit 40 | 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /datasets/ch2_ex3/lab2_ex3.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | Another useful functionality is the ability to quickly calculate summary 11 | statistics for various groups in your data frame. For example, we can modify the 12 | above command using the `group_by` function to get the same summary stats for 13 | each origin airport: 14 | 15 | ```{r load-packages, message = FALSE, echo = FALSE} 16 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the # library functions in your .Rmd file. Don't erase this code block! 17 | library(statsr) 18 | library(dplyr) 19 | library(ggplot2) 20 | 21 | # The following code is from exercise 1 to create the rdu_flights data frame 22 | rdu_flights <- nycflights %>% 23 | filter(dest == "RDU") 24 | 25 | # The following code is from exercise 1 to create the sfo_feb_flights data frame 26 | sfo_feb_flights <- nycflights %>% 27 | filter(dest == "SFO", month == 2) 28 | 29 | ``` 30 | 31 | 32 | ```{r summary-custom-list-origin} 33 | rdu_flights %>% 34 | group_by(origin) %>% 35 | summarise(mean_dd = mean(dep_delay), sd_dd = sd(dep_delay), n = n()) 36 | ``` 37 | 38 | Here, we first grouped the data by `origin`, and then calculated the summary 39 | statistics. 40 | 41 | 3. Calculate the median and interquartile range for `arr_delay`s of flights in the 42 | `sfo_feb_flights` data frame, grouped by carrier. Which carrier is the has the highest 43 | IQR of arrival delays? 44 | Answer Question 3 to the left. 45 | 46 | 47 | ```{r sfo-feb-flights-arrival-delays-carrier} 48 | # type your code for Question 3 here, and Knit 49 | 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /datasets/ch1_ex5/lab1_ex5.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to R and RStudio" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | Calculate the total number of births for each year and store these values in a new variable called `total` in the `present` dataset. 11 | 12 | In case you forgot, you can add variables to a dataset using the `$` operator. (i.e. `dataset$new_column <- dataset$column1 -+ dataset$column2`) 13 | 14 | Then, calculate the proportion of boys born each year and store these values in a new variable called `prop_boys` in the same dataset. 15 | 16 | Plot these values over time and based on the plot determine if the following statement is true or false: The proportion of boys born in the US has decreased over time. 17 | 18 | You used the following code to plot the proportion of boy births over time for the `arbuthnot` dataset. 19 | `ggplot(data = arbuthnot, aes(x = year, y = boys/total)) + geom_line() + geom_point()` 20 | 21 | 5. Calculate the total number of births for each year and store these values in a new 22 | variable called `total` in the `present` dataset. Then, calculate the proportion of 23 | boys born each year and store these values in a new variable called `prop_boys` in 24 | the same dataset. Plot these values over time and based on the plot determine if the 25 | following statement is true or false: The proportion of boys born in the US has 26 | decreased over time. Answer Question 5 to the left. 27 | 28 | ```{r load-packages, message = FALSE, echo = FALSE} 29 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 30 | library(dplyr) 31 | library(statsr) 32 | library(ggplot2) 33 | data(present) 34 | ``` 35 | 36 | 37 | 38 | ```{r prop-boys-over-time} 39 | # type your code for Question 5 here, use the output from this line to answer Question 5, and Knit 40 | 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /datasets/ch2_ex2/lab2_ex2.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 11 | ```{r load-packages, message = FALSE, echo = FALSE} 12 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 13 | library(statsr) 14 | library(dplyr) 15 | library(ggplot2) 16 | 17 | # The following code is from exercise 1 to create the sfo_feb_flights data frame 18 | sfo_feb_flights <- nycflights %>% 19 | filter(dest == "SFO", month == 2) 20 | 21 | # The following code is from exercise 1 to create the rdu_flights data frame 22 | rdu_flights <- nycflights %>% 23 | filter(dest == "RDU") 24 | 25 | # The following code is from exercise 1 to create the a plot with the rdu_flights data frame 26 | ggplot(data = rdu_flights, aes(x = dep_delay)) + 27 | geom_histogram() 28 | 29 | # The following code is from exercise 1 to summarize the rdu_flights data frame 30 | rdu_flights %>% 31 | summarise(mean_dd = mean(dep_delay), sd_dd = sd(dep_delay), n = n()) 32 | 33 | ``` 34 | Note that in the `summarise` function we created a list of two elements. The 35 | names of these elements are user defined, like `mean_dd`, `sd_dd`, `n`, and 36 | you could customize these names as you like (just don't use spaces in your 37 | names). Calculating these summary statistics also require that you know the 38 | function calls. Note that `n()` reports the sample size. 39 | 40 |
41 | **Summary statistics: ** Some useful function calls for summary statistics for a 42 | single numerical variable are as follows: 43 | 44 | - `mean` 45 | - `median` 46 | - `sd` 47 | - `var` 48 | - `IQR` 49 | - `range` 50 | - `min` 51 | - `max` 52 |
53 | 54 | 2. Make a histogram and calculate appropriate summary statistics for **arrival** 55 | delays of `sfo_feb_flights`. Which of the following is false? 56 | Answer Question 2 to the left. 57 | 58 | ```{r sfo-feb-flights-arrival-delays} 59 | # type your code for Question 2 here, and Knit 60 | 61 | ``` 62 | -------------------------------------------------------------------------------- /datasets/ch3_ex5/lab3_ex5.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Probability" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 11 | 5. How does Kobe Bryant's distribution of streak lengths compare to the distribution 12 | of streak lengths for the simulated shooter? Using this comparison, do you have 13 | evidence that the hot hand model fits Kobe's shooting patterns? 14 | Answer Question 5 to the left. 15 | 16 | ```{r load-packages, message = FALSE, echo = FALSE} 17 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 18 | library(statsr) 19 | library(dplyr) 20 | library(ggplot2) 21 | ``` 22 | 23 | We can then take a look at the distribution of these streak lengths. 24 | 25 | ## Simulating the Independent Shooter 26 | 27 | Simulating a basketball player who has independent shots uses the same mechanism 28 | that we use to simulate a coin flip. To simulate a single shot from an 29 | independent shooter with a shooting percentage of 50% we type, 30 | 31 | To make a valid comparison between Kobe and our simulated independent shooter, 32 | we need to align both their shooting percentage and the number of attempted shots. 33 | 34 | ```{r calc-streak-kobe} 35 | kobe_streak <- calc_streak(kobe_basket$shot) 36 | ``` 37 | 38 | ```{r plot-streak-kobe} 39 | ggplot(data = kobe_streak, aes(x = length)) + 40 | geom_histogram(binwidth = 1) 41 | ``` 42 | 43 | ```{r sim-basket} 44 | shot_outcomes <- c("H", "M") 45 | sim_basket <- sample(shot_outcomes, size = 1, replace = TRUE) 46 | ``` 47 | 48 | ```{r} 49 | sim_basket <- sample(shot_outcomes, size = 133, replace = TRUE, 50 | prob = c(0.45, 0.55)) 51 | ``` 52 | 53 | ```{r sim-streak-lengths} 54 | sim_streak <- calc_streak(sim_basket) 55 | ``` 56 | 57 | ```{r plot-sim-streaks} 58 | ggplot(data = sim_streak, aes(x = length)) + 59 | geom_histogram(binwidth = 1) 60 | ``` 61 | 62 |
63 | **Exercise**: What concepts from the course videos are covered in this lab? What 64 | concepts, if any, are not covered in the videos? Have you seen these concepts 65 | elsewhere, e.g. textbook, previous labs, or practice problems? 66 |
67 | 68 |
69 | This is a derivative of an [OpenIntro](https://www.openintro.org/stat/labs.php) lab, and is released under a [Attribution-NonCommercial-ShareAlike 3.0 United States](https://creativecommons.org/licenses/by-nc-sa/3.0/us/) license. 70 |
-------------------------------------------------------------------------------- /datasets/ch2_ex7/lab2_ex7.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | ### On time departure rate for NYC airports 11 | 12 | Suppose you will be flying out of NYC and want to know which of the 13 | three major NYC airports has the best on time departure rate of departing flights. 14 | Suppose also that for you a flight that is delayed for less than 5 minutes is 15 | basically "on time". You consider any flight delayed for 5 minutes of more to be 16 | "delayed". 17 | 18 | In order to determine which airport has the best on time departure rate, 19 | we need to 20 | 21 | - first classify each flight as "on time" or "delayed", 22 | - then group flights by origin airport, 23 | - then calculate on time departure rates for each origin airport, 24 | - and finally arrange the airports in descending order for on time departure 25 | percentage. 26 | 27 | Let's start with classifying each flight as "on time" or "delayed" by 28 | creating a new variable with the `mutate` function. 29 | 30 | ```{r load-packages, message = FALSE, echo = FALSE} 31 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 32 | library(statsr) 33 | library(dplyr) 34 | library(ggplot2) 35 | ``` 36 | 37 | 38 | ```{r dep-type} 39 | nycflights <- nycflights %>% 40 | mutate(dep_type = ifelse(dep_delay < 5, "on time", "delayed")) 41 | ``` 42 | 43 | The first argument in the `mutate` function is the name of the new variable 44 | we want to create, in this case `dep_type`. Then if `dep_delay < 5` we classify 45 | the flight as `"on time"` and `"delayed"` if not, i.e. if the flight is delayed 46 | for 5 or more minutes. 47 | 48 | Note that we are also overwriting the `nycflights` data frame with the new 49 | version of this data frame that includes the new `dep_type` variable. 50 | 51 | We can handle all the remaining steps in one code chunk: 52 | 53 | ```{r} 54 | nycflights %>% 55 | group_by(origin) %>% 56 | summarise(ot_dep_rate = sum(dep_type == "on time") / n()) %>% 57 | arrange(desc(ot_dep_rate)) 58 | ``` 59 | 60 | 7. If you were selecting an airport simply based on on time departure percentage, 61 | which NYC airport would you choose to fly out of? 62 | Answer Question 7 to the left. 63 | 64 | ```{r on-time-dep-perc-airport} 65 | # type your code for Question 7 here, and Knit 66 | 67 | ``` 68 | 69 | We can also visualize the distribution of on on time departure rate across 70 | the three airports using a segmented bar plot. 71 | 72 | ```{r} 73 | ggplot(data = nycflights, aes(x = origin, fill = dep_type)) + 74 | geom_bar() 75 | ``` 76 | -------------------------------------------------------------------------------- /datasets/ch1_ex8/lab1_ex8.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to R and RStudio" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | --- 11 | 12 | 8. In what year did we see the most total number of births in the U.S.? Answer Question 8 to the left. 13 | 14 | *Hint:* Sort your dataset in descending order based on the `total` column. You can do this interactively in the data viewer by clicking on the arrows next to the variable names. Or to arrange the data in a descending order with new function: `desc` (for descending order). 15 | 16 | ```{r load-packages, message = FALSE, echo = FALSE} 17 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 18 | library(dplyr) 19 | library(statsr) 20 | library(ggplot2) 21 | 22 | ``` 23 | 24 | 25 | ```{r most-total-births} 26 | # type your code for Question 8 here use the output from this line to answer Question 8 27 | # sample code is provided below, edit as necessary, uncomment, and then Knit 28 | #present %>% 29 | # mutate(total = ?) %>% 30 | # arrange(desc(total)) 31 | ``` 32 | 33 | ## Resources for learning R and working in RStudio 34 | 35 | That was a short introduction to R and RStudio, but we will provide you with more functions and a more complete sense of the language as the course progresses. You might find the following tips and resources helpful. 36 | 37 | - In this course we will be using the `dplyr` (for data wrangling) and `ggplot2` (for data visualization) extensively. If you are googling for R code, make sure to also include these package names in your search query. For example, instead of googling "scatterplot in R", google "scatterplot in R with ggplot2". 38 | 39 | - The following cheatsheets may come in handy throughout the course. Note that some of the code on these cheatsheets may be too advanced for this course, however the majority of it will become useful as you progress through the course material. 40 | - [Data wrangling cheatsheet](http://www.rstudio.com/wp-content/uploads/2015/02/data-rangling-cheatsheet.pdf) 41 | - [Data visualization cheatsheet](http://www.rstudio.com/wp-content/uploads/2015/12/ggplot2-cheatsheet-2.0.pdf) 42 | - [R Markdown](http://www.rstudio.com/wp-content/uploads/2016/03/rmarkdown-cheatsheet-2.0.pdf) 43 | 44 | - While you will get plenty of exercise working with these packages in the labs of this course, if you would like further opportunities to practice we recommend checking out the relevant courses at [DataCamp](https://www.datacamp.com/courses). 45 | 46 |
47 | This is a derivative of an [OpenIntro](https://www.openintro.org/stat/labs.php) lab, and is released under a [Attribution-NonCommercial-ShareAlike 3.0 United States](https://creativecommons.org/licenses/by-nc-sa/3.0/us/) license. 48 |
49 | -------------------------------------------------------------------------------- /datasets/ch3_ex1/lab3_ex1.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Probability" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | 11 | ## Hot Hands 12 | 13 | Basketball players who make several baskets in succession are described as 14 | having a *hot hand*. Fans and players have long believed in the hot hand 15 | phenomenon, which refutes the assumption that each shot is independent of the 16 | next. However, [a 1985 paper](http://www.sciencedirect.com/science/article/pii/0010028585900106) by Gilovich, Vallone, and Tversky collected evidence 17 | that contradicted this belief and showed that successive shots are independent 18 | events. This paper started a great controversy that continues to this day, as you can 19 | see by Googling *hot hand basketball*. 20 | 21 | We do not expect to resolve this controversy today. However, in this lab we'll 22 | apply one approach to answering questions like this. The goals for this lab are 23 | to (1) think about the effects of independent and dependent events, (2) learn 24 | how to simulate shooting streaks in R, and (3) to compare a simulation to actual 25 | data in order to determine if the hot hand phenomenon appears to be real. 26 | 27 | ## Getting Started 28 | 29 | ### Load packages 30 | 31 | In this lab we will explore the data using the `dplyr` package and visualize it 32 | using the `ggplot2` package for data visualization. The data can be found in the 33 | companion package for this course, `statsr`. 34 | 35 | Let's load the packages. 36 | 37 | ```{r load-packages, message=FALSE} 38 | library(statsr) 39 | library(dplyr) 40 | library(ggplot2) 41 | ``` 42 | 43 | ### Data 44 | 45 | Our investigation will focus on the performance of one player: Kobe Bryant of 46 | the Los Angeles Lakers. His performance against the Orlando Magic in the 2009 47 | NBA finals earned him the title *Most Valuable Player* and many spectators 48 | commented on how he appeared to show a hot hand. Let's load some necessary files 49 | that we will need for this lab. 50 | 51 | ```{r load-data} 52 | data(kobe_basket) 53 | ``` 54 | 55 | This data frame contains 133 observations and 6 variables, where every 56 | row records a shot taken by Kobe Bryant. The `shot` variable in this dataset 57 | indicates whether the shot was a hit (`H`) or a miss (`M`). 58 | 59 | Just looking at the string of hits and misses, it can be difficult to gauge 60 | whether or not it seems like Kobe was shooting with a hot hand. One way we can 61 | approach this is by considering the belief that hot hand shooters tend to go on 62 | shooting streaks. For this lab, we define the length of a shooting streak to be 63 | the *number of consecutive baskets made until a miss occurs*. 64 | 65 | For example, in Game 1 Kobe had the following sequence of hits and misses from 66 | his nine shot attempts in the first quarter: 67 | 68 | \[ \textrm{H M | M | H H M | M | M | M} \] 69 | 70 | You can verify this by viewing the first 8 rows of the data in the data viewer. 71 | 72 | Within the nine shot attempts, there are six streaks, which are separated by a 73 | "|" above. Their lengths are one, zero, two, zero, zero, zero (in order of 74 | occurrence). 75 | 76 | 1. Fill in the blank: A streak length of 1 means one \_\_\_ followed by one miss. 77 | Answer Question 1 to the left. 78 | 79 | -------------------------------------------------------------------------------- /datasets/ch1_ex2/lab1_ex2.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to R and RStudio" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 |
11 | **Exercise**: What years are included in this dataset? Hint: Take a look at the year 12 | variable in the Data Viewer to answer this question. 13 |
14 | 15 | You should see that the data frame contains the columns `year`, `boys`, and `girls`. At this point, you might notice that many of the commands in R look a lot like functions from math class; that is, invoking R commands means supplying a function with some number of arguments. The `dim` and `names` commands, for example, each took a single argument, the name of a data frame. 16 | 17 |
18 | **Tip: ** If you use the up and down arrow keys, you can scroll through your previous commands, your so-called command history. You can also access it by clicking on the history tab in the upper right panel. This will save you a lot of typing in the future. 19 |
20 | 21 | ### R Markdown 22 | 23 | So far we asked you to type your commands in the console. The console is a great place for playing around with some code, however it is not a good place for documenting your work. Working in the console exclusively makes it difficult to document your work as you go, and reproduce it later. 24 | 25 | R Markdown is a great solution for this problem. And, you already have worked with an R Markdown document -- this lab! Going forward type the code for the questions in the code chunks provided in the R Markdown (Rmd) document for the lab, and **Knit** the document to see the results. 26 | 27 | ```{r load-packages, message = FALSE, echo = FALSE} 28 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 29 | library(dplyr) 30 | library(statsr) 31 | library(ggplot2) 32 | data(arbuthnot) 33 | ``` 34 | 35 | ### Some Exploration 36 | 37 | Let's start to examine the data a little more closely. We can access the data in a single column of a data frame separately using a command like 38 | 39 | ```{r view-boys} 40 | arbuthnot$boys 41 | ``` 42 | 43 | This command will only show the number of boys baptized each year. The dollar sign basically says "go to the data frame that comes before me, and find the variable that comes after me". 44 | 45 | 2. What command would you use to extract just the counts of girls born? Answer Question 2 to the left. 46 | 47 | ```{r extract-counts-of-girls-born} 48 | # type your code for the Question 2 here, use the output from this line to answer Question 2, and Knit 49 | 50 | ``` 51 | 52 | Notice that the way R has printed these data is different. When we looked at the complete data frame, we saw 82 rows, one on each line of the display. These data are no longer structured in a table with other variables, so they are displayed one right after another. Objects that print out in this way are called vectors; they represent a set of numbers. R has added numbers in [brackets] along the left side of the printout to indicate locations within the vector. For example, 5218 follows [1], indicating that 5218 is the first entry in the vector. And if [43] starts a line, then that would mean the first number on that line would represent the 43rd entry in the vector. 53 | 54 | -------------------------------------------------------------------------------- /datasets/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex1/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex2/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex3/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex4/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex5/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex6/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex7/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex8/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex1/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex10/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex2/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex3/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex4/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex5/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex6/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex7/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex8/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch2_ex9/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch3_ex1/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch3_ex2/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch3_ex3/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch3_ex4/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch3_ex5/lab.css: -------------------------------------------------------------------------------- 1 | .fax-slot-machine:before { 2 | content: "\1f3b0" 3 | } 4 | 5 | body { 6 | counter-reset: li; /* initialize counter named li */ 7 | } 8 | 9 | h1 { 10 | font-family:Arial, Helvetica, sans-serif; 11 | font-weight:bold; 12 | } 13 | 14 | h2 { 15 | font-family:Arial, Helvetica, sans-serif; 16 | font-weight:bold; 17 | margin-top: 24px; 18 | } 19 | 20 | hr { 21 | border: 1px solid #357FAA; 22 | } 23 | 24 | ol { 25 | margin-left:0; /* Remove the default left margin */ 26 | padding-left:0; /* Remove the default left padding */ 27 | } 28 | 29 | ol > li { 30 | position:relative; /* Create a positioning context */ 31 | margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */ 32 | padding:10px 80px; /* Add some spacing around the content */ 33 | list-style:none; /* Disable the normal item numbering */ 34 | border-top:2px solid #317EAC; 35 | background:rgba(49, 126, 172, 0.1); 36 | } 37 | 38 | ol > li:before { 39 | content:"Question" ; /* Use the counter as content */ 40 | counter-increment:li; /* Increment the counter by 1 */ 41 | /* Position and style the number */ 42 | position:absolute; 43 | top:-2px; 44 | left:-2em; 45 | -moz-box-sizing:border-box; 46 | -webkit-box-sizing:border-box; 47 | box-sizing:border-box; 48 | width:7em; 49 | /* Some space between the number and the content in browsers that support 50 | generated content but not positioning it (Camino 2 is one example) */ 51 | margin-right:8px; 52 | padding:4px; 53 | border-top:2px solid #317EAC; 54 | color:#fff; 55 | background:#317EAC; 56 | font-weight:bold; 57 | font-family:"Helvetica Neue", Arial, sans-serif; 58 | text-align:center; 59 | } 60 | 61 | li ol, 62 | li ul {margin-top:6px;} 63 | 64 | ol ol{ 65 | counter-reset: subitem; 66 | } 67 | 68 | li li{ 69 | border-top:0px solid #317EAC; 70 | background:rgba(49, 126, 172, 0); 71 | padding:0px 0px; /* No spacing around the content */ 72 | } 73 | 74 | li li:before{ 75 | content: counter(subitem, upper-alpha) '. '; 76 | counter-increment: subitem; 77 | /* Position and style the number */ 78 | position:absolute; 79 | top:-2px; 80 | left:-2em; 81 | /*-moz-box-sizing:border-box;*/ 82 | /*-webkit-box-sizing:border-box;*/ 83 | box-sizing:content-box; 84 | width:1em; 85 | /* Some space between the number and the content in browsers that support 86 | generated content but not positioning it (Camino 2 is one example) */ 87 | margin-right:4px; 88 | padding:2px; 89 | border-top: initial; /*0px solid #317EAC;*/ 90 | color:#317EAC; 91 | background:transparent; 92 | font-weight:bold; 93 | font-family:"Helvetica Neue", Arial, sans-serif; 94 | text-align:center; 95 | } 96 | 97 | div#instructions { 98 | margin-top: 30px; 99 | margin-bottom: 30px; 100 | color: rgba(0, 102, 102, 0.8); 101 | border:1px solid rgba(0, 102, 102, 0.2); 102 | padding: 10px 10px; 103 | background: rgba(204, 255, 255, 0.1); 104 | border-radius: 5px; 105 | } 106 | 107 | div#license { 108 | margin-top: 30px; 109 | margin-bottom: 30px; 110 | color: rgba(76, 114, 29, 0.8); 111 | border:1px solid rgba(76, 114, 29, 0.2); 112 | padding: 10px 10px; 113 | background: rgba(76, 114, 29, 0.1); 114 | border-radius: 5px; 115 | } 116 | 117 | div#boxedtext { 118 | background-color: rgba(86, 155, 189, 0.2); 119 | padding: 20px; 120 | margin-bottom: 20px; 121 | font-size: 10pt; 122 | } 123 | 124 | div#exercise { 125 | position:relative; /* Create a positioning context */ 126 | margin:0 0 10px 0em; /* Give each list item a left margin to make room for the numbers */ 127 | padding:10px 30px; /* Add some spacing around the content */ 128 | border-top:2px solid #35CD4B; 129 | background:rgba(49, 199, 58, 0.1); 130 | } 131 | -------------------------------------------------------------------------------- /datasets/ch1_ex1/lab1_ex1.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to R and RStudio" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | The goal of this lab is to introduce you to R and RStudio, which you'll be using throughout the course both to learn the statistical concepts discussed in the course and to analyze real data and come to informed conclusions. To straighten out which is which: R is the name of the programming language itself and RStudio is a convenient interface. 11 | 12 | As the labs progress, you are encouraged to explore beyond what the labs dictate; a willingness to experiment will make you a much better programmer. Before we get to that stage, however, you need to build some basic fluency in R. Today we begin with the fundamental building blocks of R and RStudio: the interface, reading in data, and basic commands. 13 | 14 | ## RStudio 15 | 16 | Your RStudio window has four panels. 17 | 18 | Your R Markdown file (this document) is in the upper left panel. 19 | 20 | The panel on the lower left is where the action happens. It's called the *console*. Every time you launch RStudio, it will have the same text at the top of the console telling you the version of R that you're running. Below that information is the *prompt*. As its name suggests, this prompt is really a request, a request for a command. Initially, interacting with R is all about typing commands and interpreting the output. These commands and their syntax have evolved over decades (literally) and now provide what many users feel is a fairly natural way to access data and organize, describe, and invoke statistical computations. 21 | 22 | The panel in the upper right contains your *workspace* as well as a history of the commands that you've previously entered. 23 | 24 | Any plots that you generate will show up in the panel in the lower right corner. This is also where you can browse your files, access help, manage packages, etc. 25 | 26 | 27 | ## R Packages 28 | 29 | R is an open-source programming language, meaning that users can contribute packages that make our lives easier, and we can use them for free. For this lab, and many others in the future, we will use the following R packages: 30 | 31 | - `statsr`: for data files and functions used in this course 32 | - `dplyr`: for data wrangling 33 | - `ggplot2`: for data visualization 34 | 35 | You should have already installed these packages using commands like `install.packages` and `install_github`. 36 | 37 | Next, you need to load the packages in your working environment. We do this with the `library` function. Note that you only need to **install** packages once, but you need to 38 | **load** them each time you relaunch RStudio. 39 | ```{r load-packages, message = FALSE} 40 | library(dplyr) 41 | library(ggplot2) 42 | library(statsr) 43 | 44 | ``` 45 | 46 | To do so, you can 47 | 48 | - click on the green arrow at the top of the code chunk in the R Markdown (Rmd) file, or 49 | - highlight these lines, and hit the **Run** button on the upper right corner of the pane, or 50 | - type the code in the console. 51 | 52 | Going forward you will be asked to load any relevant packages at the beginning of each lab. 53 | 54 | ## Dataset 1: Dr. Arbuthnot's Baptism Records 55 | 56 | To get you started, run the following command to load the data. 57 | 58 | ```{r load-abrbuthnot-data} 59 | data(arbuthnot) 60 | ``` 61 | 62 | To do so, once again, you can 63 | 64 | - click on the green arrow at the top of the code chunk in the R Markdown (Rmd) file, or 65 | - put your cursor on this line, and hit the **Run** button on the upper right corner of the pane, or 66 | - type the code in the console. 67 | 68 | This command instructs R to load some data. The Arbuthnot baptism counts for boys and girls. You should see that the workspace area in the upper righthand corner of the RStudio window now lists a data set called `arbuthnot` that has 82 observations on 3 variables. As you interact with R, you will create a series of objects. Sometimes you load them as we have done here, and sometimes you create them yourself as the byproduct of a computation or some analysis you have performed. 69 | 70 | The Arbuthnot data set refers to Dr. John Arbuthnot, an 18th century physician, writer, and mathematician. He was interested in the ratio of newborn boys to newborn girls, so he gathered the baptism records for children born in London for every year from 1629 to 1710. We can take a look at the data by typing its name into the console. 71 | 72 | ```{r view-data} 73 | arbuthnot 74 | ``` 75 | 76 | However printing the whole dataset in the console is not that useful. One advantage of RStudio is that it comes with a built-in data viewer. Click on the name `arbuthnot` in the *Environment* pane (upper right window) that lists the objects in your workspace. This will bring up an alternative display of the data set in the *Data Viewer* (upper left window). You can close the data viewer by clicking on the *x* in the upper lefthand corner. 77 | 78 | What you should see are four columns of numbers, each row representing a different year: the first entry in each row is simply the row number (an index we can use to access the data from individual years if we want), the second is the year, and the third and fourth are the numbers of boys and girls baptized that year, respectively. Use the scrollbar on the right side of the console window to examine the complete data set. 79 | 80 | Note that the row numbers in the first column are not part of Arbuthnot's data. R adds them as part of its printout to help you make visual comparisons. You can think of them as the index that you see on the left side of a spreadsheet. In fact, the comparison to a spreadsheet will generally be helpful. R has stored Arbuthnot's data in a kind of spreadsheet or table called a *data frame*. 81 | 82 | You can see the dimensions of this data frame by typing: 83 | 84 | ```{r dim-data} 85 | # use the output from this line to answer Question 1, and Knit 86 | dim(arbuthnot) 87 | ``` 88 | 89 | This command should output `[1] 82 3`, indicating that there are 82 rows and 3 columns (we'll get to what the `[1]` means in a bit), just as it says next to the object in your workspace. You can see the names of these columns (or variables) by typing: 90 | 91 | ```{r names-data} 92 | names(arbuthnot) 93 | ``` 94 | 95 | 1. How many variables are included in this data set? Answer Question 1 to the left. 96 | -------------------------------------------------------------------------------- /datasets/ch1_ex3/lab1_ex3.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to R and RStudio" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | R has some powerful functions for making graphics. We can create a simple plot of the number of girls baptized per year with the command 10 | 11 | ```{r load-packages, message = FALSE, echo=FALSE} 12 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 13 | library(dplyr) 14 | library(statsr) 15 | library(ggplot2) 16 | data(arbuthnot) 17 | ``` 18 | 19 | ```{r plot-girls-vs-year} 20 | # use the plot created in this block to answer Question 3, and Knit 21 | ggplot(data = arbuthnot, aes(x = year, y = girls)) + 22 | geom_point() 23 | ``` 24 | 25 | Before we review the code for this plot, let's summarize the trends we see in the data. 26 | 27 | 3. Which of the following best describes the number of girls baptised over the years included in this dataset? Answer Question 3 to the left. 28 | 29 | 30 | Back to the code... We use the `ggplot()` function to build plots. If you run the plotting code in your console, you should see the plot appear under the *Plots* tab of the lower right panel of RStudio. Notice that the command above again looks like a function, this time with arguments separated by commas. 31 | 32 | - The first argument is always the dataset. 33 | - Next, we provide thevariables from the dataset to be assigned to `aes`thetic elements of the plot, e.g. the x and the y axes. 34 | - Finally, we use another layer, separated by a `+` to specify the `geom`etric object for the plot. Since we want to scatterplot, we use `geom_point`. 35 | 36 | You might wonder how you are supposed to know the syntax for the `ggplot` function. Thankfully, R documents all of its functions extensively. To read what a function does and learn the arguments that are available to you, just type in a question mark followed by the name of the function that you're interested in. Try the following in your console: 37 | 38 | ```{r plot-help, tidy = FALSE} 39 | ?ggplot 40 | ``` 41 | 42 | Notice that the help file replaces the plot in the lower right panel. You can toggle between plots and help files using the tabs at the top of that panel. 43 | 44 |
45 | More extensive help for plotting with the `ggplot2` package can be found at http://docs.ggplot2.org/current/. The best (and easiest) way to learn the syntax is to take a look at the sample plots provided on that page, and modify the code bit by bit until you get achieve the plot you want. 46 |
47 | 48 | ### R as a big calculator 49 | 50 | Now, suppose we want to plot the total number of baptisms. To compute this, we could use the fact that R is really just a big calculator. We can type in mathematical expressions like 51 | 52 | ```{r calc-total-bapt-numbers} 53 | 5218 + 4683 54 | ``` 55 | 56 | to see the total number of baptisms in 1629. We could repeat this once for each year, but there is a faster way. If we add the vector for baptisms for boys to that of girls, R will compute all sums simultaneously. 57 | 58 | ```{r calc-total-bapt-vars} 59 | arbuthnot$boys + arbuthnot$girls 60 | ``` 61 | 62 | What you will see are 82 numbers (in that packed display, because we aren’t looking at a 63 | data frame here), each one representing the sum we’re after. Take a look at a few of them and verify that they are right. 64 | 65 | ### Adding a new variable to the data frame 66 | 67 | We'll be using this new vector to generate some plots, so we'll want to save it as a permanent column in our data frame. 68 | 69 | ```{r calc-total-bapt-vars-save} 70 | arbuthnot <- arbuthnot %>% 71 | mutate(total = boys + girls) 72 | ``` 73 | 74 | What in the world is going on here? The `%>%` operator is called the **piping** operator. 75 | Basically, it takes the output of the current line and pipes it into the following line of code. 76 | 77 |
78 | **A note on piping: ** Note that we can read these three lines of code as the following: 79 | 80 | *"Take the `arbuthnot` dataset and **pipe** it into the `mutate` function. Using this mutate a new variable called `total` that is the sum of the variables called `boys` and `girls`. Then assign this new resulting dataset to the object called `arbuthnot`, i.e. overwrite the old `arbuthnot` dataset with the new one containing the new variable."* 81 | 82 | This is essentially equivalent to going through each row and adding up the boys 83 | and girls counts for that year and recording that value in a new column called total. 84 |
85 | 86 |
87 | **Where is the new variable? ** When you make changes to variables in your dataset, click on the name of the dataset again to update it in the data viewer. 88 |
89 | 90 | You'll see that there is now a new column called `total` that has been tacked on to the data frame. The special symbol `<-` performs an *assignment*, taking the output of one line of code and saving it into an object in your workspace. In this case, you already have an object called `arbuthnot`, so this command updates that data set with the new mutated column. 91 | 92 | We can make a plot of the total number of baptisms per year with the following command. 93 | 94 | ```{r plot-total-vs-year-line} 95 | ggplot(data = arbuthnot, aes(x = year, y = total)) + 96 | geom_line() 97 | ``` 98 | 99 | Note that using `geom_line()` instead of `geom_point()` results in a line plot instead of a scatter plot. You want both? Just layer them on: 100 | 101 | ```{r plot-total-vs-year-line-and-point} 102 | ggplot(data = arbuthnot, aes(x = year, y = total)) + 103 | geom_line() + 104 | geom_point() 105 | ``` 106 | 107 |
108 | **Exercise**: Now, generate a plot of the proportion of boys born over time. What do you see? 109 |
110 | 111 | ```{r plot-proportion-of-boys-over-time} 112 | # type your code for the Exercise here, and Knit 113 | 114 | ``` 115 | 116 | Finally, in addition to simple mathematical operators like subtraction and division, you can ask R to make comparisons like greater than, `>`, less than, `<`, and equality, `==`. For example, we can ask if boys outnumber girls in each year with the expression 117 | 118 | ```{r boys-more-than-girls} 119 | arbuthnot <- arbuthnot %>% 120 | mutate(more_boys = boys > girls) 121 | ``` 122 | 123 | This command add a new variable to the `arbuthnot` data frame containing the values of either `TRUE` if that year had more boys than girls, or `FALSE` if that year did not (the answer may surprise you). This variable contains different kind of data than we have considered so far. All other columns in the `arbuthnot` data frame have values are numerical (the year, the number of boys and girls). Here, we've asked R to create *logical* data, data where the values are either `TRUE`or `FALSE`. In general, data analysis will involve many different kinds of data types, and one reason for using R is that it is able to represent and compute with many of them. 124 | 125 | -------------------------------------------------------------------------------- /datasets/ch3_ex4/lab3_ex4.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Probability" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | ## Compared to What? 11 | 12 | We've shown that Kobe had some long shooting streaks, but are they long enough 13 | to support the belief that he had hot hands? What can we compare them to? 14 | 15 | To answer these questions, let's return to the idea of *independence*. Two 16 | processes are independent if the outcome of one process doesn't effect the outcome 17 | of the second. If each shot that a player takes is an independent process, 18 | having made or missed your first shot will not affect the probability that you 19 | will make or miss your second shot. 20 | 21 | A shooter with a hot hand will have shots that are *not* independent of one 22 | another. Specifically, if the shooter makes his first shot, the hot hand model 23 | says he will have a *higher* probability of making his second shot. 24 | 25 | Let's suppose for a moment that the hot hand model is valid for Kobe. During his 26 | career, the percentage of time Kobe makes a basket (i.e. his shooting 27 | percentage) is about 45%, or in probability notation, 28 | 29 | \[ P(\textrm{shot 1 = H}) = 0.45 \] 30 | 31 | If he makes the first shot and has a hot hand (*not* independent shots), then 32 | the probability that he makes his second shot would go up to, let's say, 60%, 33 | 34 | \[ P(\textrm{shot 2 = H} \, | \, \textrm{shot 1 = H}) = 0.60 \] 35 | 36 | As a result of these increased probabilites, you'd expect Kobe to have longer 37 | streaks. Compare this to the skeptical perspective where Kobe does *not* have a 38 | hot hand, where each shot is independent of the next. If he hit his first shot, 39 | the probability that he makes the second is still 0.45. 40 | 41 | \[ P(\textrm{shot 2 = H} \, | \, \textrm{shot 1 = H}) = 0.45 \] 42 | 43 | In other words, making the first shot did nothing to effect the probability that 44 | he'd make his second shot. If Kobe's shots are independent, then he'd have the 45 | same probability of hitting every shot regardless of his past shots: 45%. 46 | 47 | Now that we've phrased the situation in terms of independent shots, let's return 48 | to the question: how do we tell if Kobe's shooting streaks are long enough to 49 | indicate that he has hot hands? We can compare his streak lengths to someone 50 | without hot hands: an independent shooter. 51 | 52 | ## Simulations in R 53 | 54 | While we don't have any data from a shooter we know to have independent shots, 55 | that sort of data is very easy to simulate in R. In a simulation, you set the 56 | ground rules of a random process and then the computer uses random numbers to 57 | generate an outcome that adheres to those rules. As a simple example, you can 58 | simulate flipping a fair coin with the following. 59 | 60 | ```{r load-packages, message = FALSE, echo = FALSE} 61 | # Although the packages ggplot2, dplyr, and statsr are loaded, to Knit, you must have the library functions in your .Rmd file. Don't erase this code block! 62 | library(statsr) 63 | library(dplyr) 64 | library(ggplot2) 65 | ``` 66 | 67 | 68 | ```{r head-tail} 69 | coin_outcomes <- c("heads", "tails") 70 | sample(coin_outcomes, size = 1, replace = TRUE) 71 | ``` 72 | 73 | The vector `outcomes` can be thought of as a hat with two slips of paper in it: 74 | one slip says `heads` and the other says `tails`. The function `sample` draws 75 | one slip from the hat and tells us if it was a head or a tail. 76 | 77 | Run the second command listed above several times. Just like when flipping a 78 | coin, sometimes you'll get a heads, sometimes you'll get a tails, but in the 79 | long run, you'd expect to get roughly equal numbers of each. 80 | 81 | If you wanted to simulate flipping a fair coin 100 times, you could either run 82 | the function 100 times or, more simply, adjust the `size` argument, which 83 | governs how many samples to draw (the `replace = TRUE` argument indicates we put 84 | the slip of paper back in the hat before drawing again). Save the resulting 85 | vector of heads and tails in a new object called `sim_fair_coin`. 86 | 87 | ```{r sim-fair-coin} 88 | sim_fair_coin <- sample(coin_outcomes, size = 100, replace = TRUE) 89 | ``` 90 | 91 | To view the results of this simulation, type the name of the object and then use 92 | `table` to count up the number of heads and tails. 93 | 94 | ```{r table-sim-fair-coin} 95 | sim_fair_coin 96 | table(sim_fair_coin) 97 | ``` 98 | 99 | Since there are only two elements in `outcomes`, the probability that we "flip" 100 | a coin and it lands heads is 0.5. Say we're trying to simulate an unfair coin 101 | that we know only lands heads 20% of the time. We can adjust for this by adding 102 | an argument called `prob`, which provides a vector of two probability weights. 103 | 104 | ```{r sim-unfair-coin} 105 | sim_unfair_coin <- sample(coin_outcomes, size = 100, replace = TRUE, 106 | prob = c(0.2, 0.8)) 107 | ``` 108 | 109 | `prob = c(0.2, 0.8)` indicates that for the two elements in the `outcomes` vector, 110 | we want to select the first one, `heads`, with probability 0.2 and the second 111 | one, `tails` with probability 0.8. Another way of thinking about this is to 112 | think of the outcome space as a bag of 10 chips, where 2 chips are labeled 113 | "head" and 8 chips "tail". Therefore at each draw, the probability of drawing a 114 | chip that says "head"" is 20%, and "tail" is 80%. 115 | 116 |
117 | **Exercise**: In your simulation of flipping the unfair coin 100 times, how many flips came up heads? 118 |
119 | 120 | In a sense, we've shrunken the size of the slip of paper that says "heads", 121 | making it less likely to be drawn and we've increased the size of the slip of 122 | paper saying "tails", making it more likely to be drawn. When we simulated the 123 | fair coin, both slips of paper were the same size. This happens by default if 124 | you don't provide a `prob` argument; all elements in the `outcomes` vector have 125 | an equal probability of being drawn. 126 | 127 | If you want to learn more about `sample` or any other function, recall that you 128 | can always check out its help file with `?sample`. 129 | 130 | 131 | ## Simulating the Independent Shooter 132 | 133 | Simulating a basketball player who has independent shots uses the same mechanism 134 | that we use to simulate a coin flip. To simulate a single shot from an 135 | independent shooter with a shooting percentage of 50% we type, 136 | 137 | ```{r sim-basket} 138 | shot_outcomes <- c("H", "M") 139 | sim_basket <- sample(shot_outcomes, size = 1, replace = TRUE) 140 | ``` 141 | 142 | To make a valid comparison between Kobe and our simulated independent shooter, 143 | we need to align both their shooting percentage and the number of attempted shots. 144 | 145 | 146 |
147 | **Exercise**: What change needs to be made to the `sample` function so that it reflects a shooting percentage of 45%? Make this adjustment, then run a simulation to sample 133 shots. Assign the output of this simulation to a new object called `sim_basket`. 148 |
149 | 150 | Note that we've named the new vector `sim_basket`, the same name that we gave to 151 | the previous vector reflecting a shooting percentage of 50%. In this situation, 152 | R overwrites the old object with the new one, so always make sure that you don't 153 | need the information in an old vector before reassigning its name. 154 | 155 | With the results of the simulation saved as `sim_basket`, we have the data 156 | necessary to compare Kobe to our independent shooter. 157 | 158 | Both data sets represent the results of 133 shot attempts, each with the same 159 | shooting percentage of 45%. We know that our simulated data is from a shooter 160 | that has independent shots. That is, we know the simulated shooter does not have 161 | a hot hand. 162 | 163 | ### Comparing Kobe Bryant to the Independent Shooter 164 | 165 |
166 | **Exercise**: Using `calc_streak`, compute the streak lengths of `sim_basket`, and save the results in a data frame called `sim_streak`. Note that since the `sim_streak` object is just a vector and not a variable in a data frame, we don't need to first select it from a data frame like we did earlier when we calculated the streak lengths for Kobe's shots. 167 |
168 | ```{r sim-streak-lengths} 169 | # type your code for the Exercise here, and Knit 170 | 171 | ``` 172 | 173 |
174 | **Exercise**: Make a plot of the distribution of simulated streak lengths of the independent shooter. What is the typical streak length for this simulated independent shooter with a 45% shooting percentage? How long is the player's longest streak of baskets in 133 shots? 175 |
176 | ```{r plot-sim-streaks} 177 | # type your code for the Exercise here, and Knit 178 | 179 | ``` 180 | 181 | 4. If you were to run the simulation of the independent shooter a second time, how 182 | would you expect its streak distribution to compare to the distribution from the 183 | exercise above? 184 | Answer Question 4 to the left. 185 | 186 | -------------------------------------------------------------------------------- /chapter3.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Lab 3 - Probability' 3 | description: 'Questions for Lab 3' 4 | --- 5 | 6 | ## Question 1 7 | 8 | ```yaml 9 | type: ExplorableExercise 10 | key: 02d4222b54 11 | xp: 50 12 | skills: 1 13 | ``` 14 | 15 | Follow the directions in the console to open the R Markdown file: 16 | 17 | ```Type 'go()' and hit Enter to get started!``` 18 | 19 | You can use the RStudio platform just like you would on your home computer. 20 | 21 | The markdown file contains the instuctions to answer the multiple choice question below. 22 | 23 | Q1. Fill in the blank: A streak length of 1 means one ___ followed by one miss. 24 | 25 | `@possible_answers` 26 | - hit 27 | - miss 28 | 29 | `@hint` 30 | Check out the instructions in the .Rmd file to answer the multiple choice question. 31 | 32 | `@pre_exercise_code` 33 | ```{r} 34 | # Import the helper file contained in the image 35 | source('/usr/local/lib/R/site-library/run_rstudio.R') 36 | 37 | # Run a new RStudio session and serve it to the user 38 | run_rstudio(3, 1) 39 | 40 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex1.Rprofile 41 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex1.init.R 42 | # lab3_ex1.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex1.Rmd 43 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 44 | ``` 45 | 46 | `@sct` 47 | ```{r,eval=FALSE} 48 | msg1 <- "Great work!" 49 | msg2 <- "Try again." 50 | 51 | ex() %>% check_mc(1, feedback_msgs = c(msg1, msg2)) 52 | ``` 53 | 54 | --- 55 | 56 | ## Question 2 57 | 58 | ```yaml 59 | type: ExplorableExercise 60 | key: 5440b387f2 61 | xp: 50 62 | skills: 1 63 | ``` 64 | 65 | Follow the directions in the console to open the R Markdown file. 66 | 67 | You can use the RStudio platform just like you would on your home computer. 68 | 69 | The markdown file contains the instuctions to answer the multiple choice question below. 70 | 71 | Q2. Fill in the blank: A streak length of 0 means one ___ which must occur after a miss that ended the preceeding streak. 72 | 73 | `@possible_answers` 74 | - hit 75 | - miss 76 | 77 | `@hint` 78 | Check out the instructions in the .Rmd file to answer the multiple choice question. 79 | 80 | `@pre_exercise_code` 81 | ```{r} 82 | # Import the helper file contained in the image 83 | source('/usr/local/lib/R/site-library/run_rstudio.R') 84 | 85 | # Run a new RStudio session and serve it to the user 86 | run_rstudio(3, 2) 87 | 88 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex2.Rprofile 89 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex2.init.R 90 | # lab3_ex2.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex2.Rmd 91 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 92 | ``` 93 | 94 | `@sct` 95 | ```{r,eval=FALSE} 96 | msg1 <- "Try again." 97 | msg2 <- "Great work!" 98 | 99 | ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2)) 100 | ``` 101 | 102 | --- 103 | 104 | ## Question 3 105 | 106 | ```yaml 107 | type: ExplorableExercise 108 | key: eb6689ed9c 109 | xp: 50 110 | skills: 1 111 | ``` 112 | 113 | Follow the directions in the console to open the R Markdown file. 114 | 115 | You can use the RStudio platform just like you would on your home computer. 116 | 117 | The markdown file contains the instuctions to answer the multiple choice question below. 118 | 119 | Q3. Which of the following is false about the distribution of Kobe's streak lengths from the 2009 NBA finals? 120 | 121 | `@possible_answers` 122 | - The distribution of Kobe's streaks is unimodal and right skewed. 123 | - The typical length of a streak is 0 since the median of the distribution is at 0. 124 | - The IQR of the distribution is 1. 125 | - The longest streak of baskets is of length 4. 126 | - The shortest streak is of length 1. 127 | 128 | `@hint` 129 | Check out the instructions in the .Rmd file to answer the multiple choice question. 130 | 131 | `@pre_exercise_code` 132 | ```{r} 133 | # Import the helper file contained in the image 134 | source('/usr/local/lib/R/site-library/run_rstudio.R') 135 | 136 | # Run a new RStudio session and serve it to the user 137 | run_rstudio(3, 3) 138 | 139 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex3.Rprofile 140 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex3.init.R 141 | # lab3_ex3.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex3.Rmd 142 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 143 | ``` 144 | 145 | `@sct` 146 | ```{r,eval=FALSE} 147 | msg1 <- "Try again." 148 | msg2 <- "Not quite!" 149 | msg3 <- "Keep trying!" 150 | msg4 <- "Try again." 151 | msg5 <- "Awesome!" 152 | 153 | ex() %>% check_mc(5, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5)) 154 | ``` 155 | 156 | --- 157 | 158 | ## Question 4 159 | 160 | ```yaml 161 | type: ExplorableExercise 162 | key: e64497e7f4 163 | xp: 50 164 | skills: 1 165 | ``` 166 | 167 | Follow the directions in the console to open the R Markdown file. 168 | 169 | You can use the RStudio platform just like you would on your home computer. 170 | 171 | The markdown file contains the instuctions to answer the multiple choice question below. 172 | 173 | Q4. If you were to run the simulation of the independent shooter a second time, how would you expect its streak distribution to compare to the distribution from the exercise above? 174 | 175 | `@possible_answers` 176 | - Exactly the same 177 | - Somewhat similar 178 | - Totally different 179 | 180 | `@hint` 181 | Check out the instructions in the .Rmd file to answer the multiple choice question. 182 | 183 | `@pre_exercise_code` 184 | ```{r} 185 | # Import the helper file contained in the image 186 | source('/usr/local/lib/R/site-library/run_rstudio.R') 187 | 188 | # Run a new RStudio session and serve it to the user 189 | run_rstudio(3, 4) 190 | 191 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex4.Rprofile 192 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex4.init.R 193 | # lab3_ex4.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex4.Rmd 194 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 195 | ``` 196 | 197 | `@sct` 198 | ```{r,eval=FALSE} 199 | msg1 <- "Try again." 200 | msg2 <- "You got it!" 201 | msg3 <- "Keep trying!" 202 | 203 | ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3)) 204 | ``` 205 | 206 | --- 207 | 208 | ## Question 5 209 | 210 | ```yaml 211 | type: ExplorableExercise 212 | key: b073c8a4d3 213 | xp: 50 214 | skills: 1 215 | ``` 216 | 217 | Follow the directions in the console to open the R Markdown file. 218 | 219 | You can use the RStudio platform just like you would on your home computer. 220 | 221 | The markdown file contains the instuctions to answer the multiple choice question below. 222 | 223 | Q5. How does Kobe Bryant's distribution of streak lengths compare to the distribution of streak lengths for the simulated shooter? Using this comparison, do you have evidence that the hot hand model fits Kobe's shooting patterns? 224 | 225 | `@possible_answers` 226 | - The distributions look very similar. Therefore, there doesn't appear to be evidence for Kobe Bryant's hot hand. 227 | - The distributions look very similar. Therefore, there appears to be evidence for Kobe Bryant's hot hand. 228 | - The distributions look very different. Therefore, there doesn't appear to be evidence for Kobe Bryant's hot hand. 229 | - The distributions look very different. Therefore, there appears to be evidence for Kobe Bryant's hot hand. 230 | 231 | `@hint` 232 | Check out the instructions in the .Rmd file to answer the multiple choice question. 233 | 234 | `@pre_exercise_code` 235 | ```{r} 236 | # Import the helper file contained in the image 237 | source('/usr/local/lib/R/site-library/run_rstudio.R') 238 | 239 | # Run a new RStudio session and serve it to the user 240 | run_rstudio(3, 5) 241 | 242 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex5.Rprofile 243 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex5.init.R 244 | # lab3_ex5.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab3_ex5.Rmd 245 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 246 | ``` 247 | 248 | `@sct` 249 | ```{r,eval=FALSE} 250 | msg1 <- "Awesome!" 251 | msg2 <- "Try again." 252 | msg3 <- "Nope, Try again." 253 | msg4 <- "Not qute, Try again." 254 | 255 | ex() %>% check_mc(1, feedback_msgs = c(msg1, msg2, msg3, msg4)) 256 | success_msg("Click [here](https://assets.datacamp.com/production/repositories/302/datasets/10379ce0508b5f53c01f73b6afaf7a7623459bf2/ch3_key.Rmd) to get a complete Rmarkdown file of the exercises in this Lab and click [here](https://assets.datacamp.com/production/repositories/302/datasets/c7ad825dd2191d71abef274ce662c7c9dd3e33b6/ch3_key.html) to get the Knitted HTML output.") 257 | ``` 258 | -------------------------------------------------------------------------------- /datasets/ch2_ex1/lab2_ex1.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to data" 3 | output: 4 | html_document: 5 | theme: cerulean 6 | highlight: pygments 7 | css: lab.css 8 | --- 9 | 10 | Some define statistics as the field that focuses on turning information into 11 | knowledge. The first step in that process is to summarize and describe the raw 12 | information - the data. In this lab we explore flights, specifically a random 13 | sample of domestic flights that departed from the three major 14 | New York City airports in 2013. We will generate simple graphical and numerical 15 | summaries of data on these flights and explore delay times. As this is a large 16 | data set, along the way you'll also learn the indispensable skills of data 17 | processing and subsetting. 18 | 19 | ## Getting started 20 | 21 | ### Load packages 22 | 23 | In this lab we will explore the data using the `dplyr` package and visualize it 24 | using the `ggplot2` package for data visualization. The data can be found in the 25 | companion package for this course, `statsr`. 26 | 27 | Let's load the packages. 28 | 29 | ```{r load-packages, message=FALSE} 30 | library(statsr) 31 | library(dplyr) 32 | library(ggplot2) 33 | ``` 34 | 35 | ### Data 36 | 37 | The [Bureau of Transportation Statistics](http://www.rita.dot.gov/bts/about/) 38 | (BTS) is a statistical agency that is a part of the Research and Innovative 39 | Technology Administration (RITA). As its name implies, BTS collects and makes 40 | available transportation data, such as the flights data we will be working with 41 | in this lab. 42 | 43 | We begin by loading the `nycflights` data frame. Type the following in your console 44 | to load the data: 45 | 46 | ```{r load-data} 47 | data(nycflights) 48 | ``` 49 | 50 | The data frame containing `r nrow(nycflights)` flights that shows up in your 51 | workspace is a *data matrix*, with each row representing an *observation* and each 52 | column representing a *variable*. R calls this data format a **data frame**, which is 53 | a term that will be used throughout the labs. 54 | 55 | To view the names of the variables, type the command 56 | 57 | ```{r names} 58 | names(nycflights) 59 | ``` 60 | 61 | This returns the names of the variables in this data frame. The **codebook** 62 | (description of the variables) is included below. This information can also be 63 | found in the help file for the data frame which can be accessed by typing 64 | `?nycflights` in the console. 65 | 66 | - `year`, `month`, `day`: Date of departure 67 | - `dep_time`, `arr_time`: Departure and arrival times, local timezone. 68 | - `dep_delay`, `arr_delay`: Departure and arrival delays, in minutes. Negative times represent early departures/arrivals. 69 | - `carrier`: Two letter carrier abbreviation. 70 | + `9E`: Endeavor Air Inc. 71 | + `AA`: American Airlines Inc. 72 | + `AS`: Alaska Airlines Inc. 73 | + `B6`: JetBlue Airways 74 | + `DL`: Delta Air Lines Inc. 75 | + `EV`: ExpressJet Airlines Inc. 76 | + `F9`: Frontier Airlines Inc. 77 | + `FL`: AirTran Airways Corporation 78 | + `HA`: Hawaiian Airlines Inc. 79 | + `MQ`: Envoy Air 80 | + `OO`: SkyWest Airlines Inc. 81 | + `UA`: United Air Lines Inc. 82 | + `US`: US Airways Inc. 83 | + `VX`: Virgin America 84 | + `WN`: Southwest Airlines Co. 85 | + `YV`: Mesa Airlines Inc. 86 | - `tailnum`: Plane tail number 87 | - `flight`: Flight number 88 | - `origin`, `dest`: Airport codes for origin and destination. (Google can help 89 | you with what code stands for which airport.) 90 | - `air_time`: Amount of time spent in the air, in minutes. 91 | - `distance`: Distance flown, in miles. 92 | - `hour`, `minute`: Time of departure broken in to hour and minutes. 93 | 94 | A very useful function for taking a quick peek at your data frame, and viewing 95 | its dimensions and data types is `str`, which stands for **str**ucture. 96 | 97 | ```{r str} 98 | str(nycflights) 99 | ``` 100 | 101 | The `nycflights` data frame is a massive trove of information. Let's think about 102 | some questions we might want to answer with these data: 103 | 104 | - We might want to find out how delayed flights headed to a particular 105 | destination tend to be. 106 | - We might want to evaluate how departure delays vary over months. 107 | - Or we might want to determine which of the three major NYC airports has a better 108 | on-time percentage for departing flights. 109 | 110 | ### Seven verbs 111 | 112 | The `dplyr` package offers seven verbs (functions) for basic data 113 | manipulation: 114 | 115 | - `filter()` 116 | - `arrange()` 117 | - `select()` 118 | - `distinct()` 119 | - `mutate()` 120 | - `summarise()` 121 | - `sample_n()` 122 | 123 | We will use some of these functions in this lab, and learn about others in a 124 | future lab. 125 | 126 | 127 | ## Analysis 128 | 129 | ### Departure delays in flights to Raleigh-Durham (RDU) 130 | 131 | We can examine the distribution of departure delays of all flights with a 132 | histogram. 133 | 134 | ```{r hist-dep-delay} 135 | ggplot(data = nycflights, aes(x = dep_delay)) + 136 | geom_histogram() 137 | ``` 138 | 139 | This function says to plot the `dep_delay` variable from the `nycflights` data 140 | frame on the x-axis. It also defines a `geom` (short for geometric object), 141 | which describes the type of plot you will produce. 142 | 143 | Histograms are generally a very good way to see the shape of a single 144 | distribution, but that shape can change depending on how the data is split 145 | between the different bins. You can easily define the binwidth you want to use: 146 | 147 | ```{r hist-dep-delay-bins} 148 | ggplot(data = nycflights, aes(x = dep_delay)) + 149 | geom_histogram(binwidth = 15) 150 | ggplot(data = nycflights, aes(x = dep_delay)) + 151 | geom_histogram(binwidth = 150) 152 | ``` 153 | 154 |
155 | **Exercise**: How do these three histograms with the various binwidths compare? 156 |
157 | 158 | If we want to focus on departure delays of flights headed to RDU only, we need to 159 | first `filter` the data for flights headed to RDU (`dest == "RDU"`) and then make 160 | a histogram of only departure delays of only those flights. 161 | 162 | ```{r rdu-flights-hist} 163 | rdu_flights <- nycflights %>% 164 | filter(dest == "RDU") 165 | ggplot(data = rdu_flights, aes(x = dep_delay)) + 166 | geom_histogram() 167 | ``` 168 | 169 | Let's decipher these three lines of code: 170 | 171 | - Line 1: Take the `nycflights` data frame, `filter` for flights headed to RDU, and 172 | save the result as a new data frame called `rdu_flights`. 173 | + `==` means "if it's equal to". 174 | + `RDU` is in quotation marks since it is a character string. 175 | - Line 2: Basically the same `ggplot` call from earlier for making a histogram, 176 | except that it uses the data frame for flights headed to RDU instead of all 177 | flights. 178 | 179 |
180 | **Logical operators: ** Filtering for certain observations (e.g. flights from a 181 | particular airport) is often of interest in data frames where we might want to 182 | examine observations with certain characteristics separately from the rest of 183 | the data. To do so we use the `filter` function and a series of 184 | **logical operators**. The most commonly used logical operators for data 185 | analysis are as follows: 186 | 187 | - `==` means "equal to" 188 | - `!=` means "not equal to" 189 | - `>` or `<` means "greater than" or "less than" 190 | - `>=` or `<=` means "greater than or equal to" or "less than or equal to" 191 |
192 | 193 | We can also obtain numerical summaries for these flights: 194 | 195 | ```{r rdu-flights-summ} 196 | rdu_flights %>% 197 | summarise(mean_dd = mean(dep_delay), sd_dd = sd(dep_delay), n = n()) 198 | ``` 199 | 200 | Note that in the `summarise` function we created a list of two elements. The 201 | names of these elements are user defined, like `mean_dd`, `sd_dd`, `n`, and 202 | you could customize these names as you like (just don't use spaces in your 203 | names). Calculating these summary statistics also require that you know the 204 | function calls. Note that `n()` reports the sample size. 205 | 206 |
207 | **Summary statistics: ** Some useful function calls for summary statistics for a 208 | single numerical variable are as follows: 209 | 210 | - `mean` 211 | - `median` 212 | - `sd` 213 | - `var` 214 | - `IQR` 215 | - `range` 216 | - `min` 217 | - `max` 218 |
219 | 220 | We can also filter based on multiple criteria. Suppose we are interested in 221 | flights headed to San Francisco (SFO) in February: 222 | 223 | ```{r} 224 | sfo_feb_flights <- nycflights %>% 225 | filter(dest == "SFO", month == 2) 226 | ``` 227 | 228 | Note that we can separate the conditions using commas if we want flights that 229 | are both headed to SFO **and** in February. If we are interested in either 230 | flights headed to SFO **or** in February we can use the `|` instead of the comma. 231 | 232 | 1. Create a new data frame that includes flights headed to SFO in February, and save 233 | this data frame as `sfo_feb_flights`. How many flights meet these criteria? 234 | Answer Question 1 to the left. 235 | 236 | ```{r sfo-feb-flights} 237 | # type your code for Question 1 here, and Knit 238 | 239 | ``` 240 | -------------------------------------------------------------------------------- /chapter1.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Lab 1 - Intro to probability and data' 3 | description: 'Questions for Lab 1' 4 | --- 5 | 6 | ## Question 1 7 | 8 | ```yaml 9 | type: ExplorableExercise 10 | key: 02d4222b54 11 | xp: 50 12 | skills: 1 13 | ``` 14 | 15 | Follow the directions in the console to open the R Markdown file: 16 | 17 | ```Type 'go()' and hit Enter to get started!``` 18 | 19 | You can use the RStudio platform just like you would on your home computer. 20 | 21 | The markdown file contains the instuctions to answer the multiple choice question below. 22 | 23 | Q1. How many variables are included in this data set? 24 | 25 | `@possible_answers` 26 | - 2 27 | - 3 28 | - 4 29 | - 82 30 | - 1710 31 | 32 | `@hint` 33 | Check out the instructions in the .Rmd file to answer the multiple choice question. 34 | 35 | `@pre_exercise_code` 36 | ```{r} 37 | # Import the helper file contained in the image 38 | source('/usr/local/lib/R/site-library/run_rstudio.R') 39 | 40 | # Run a new RStudio session and serve it to the user 41 | run_rstudio(1, 1) 42 | 43 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex1.Rprofile 44 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex1.init.R 45 | # lab1_ex1.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex1.Rmd 46 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 47 | ``` 48 | 49 | `@sct` 50 | ```{r,eval=FALSE} 51 | msg1 <- "Try again." 52 | msg2 <- "Great work!" 53 | msg3 <- "Keep trying!" 54 | msg4 <- "Nope." 55 | msg5 <- "Not quite." 56 | ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5)) 57 | ``` 58 | 59 | --- 60 | 61 | ## Question 2 62 | 63 | ```yaml 64 | type: ExplorableExercise 65 | key: 5440b387f2 66 | xp: 50 67 | skills: 1 68 | ``` 69 | 70 | Follow the directions in the console to open the R Markdown file. 71 | 72 | You can use the RStudio platform just like you would on your home computer. 73 | 74 | The markdown file contains the instuctions to answer the multiple choice question below. 75 | 76 | Q2. What command would you use to extract just the counts of girls born? 77 | 78 | `@possible_answers` 79 | - `arbuthnot$boys` 80 | - `arbuthnot$girls` 81 | - `girls` 82 | - `arbuthnot[girls]` 83 | - `$girls` 84 | 85 | `@hint` 86 | Check out the instructions in the .Rmd file to answer the multiple choice question. 87 | 88 | `@pre_exercise_code` 89 | ```{r} 90 | # Import the helper file contained in the image 91 | source('/usr/local/lib/R/site-library/run_rstudio.R') 92 | 93 | # Run a new RStudio session and serve it to the user 94 | run_rstudio(1, 2) 95 | 96 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex2.Rprofile 97 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex2.init.R 98 | # lab1_ex2.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex2.Rmd 99 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 100 | ``` 101 | 102 | `@sct` 103 | ```{r,eval=FALSE} 104 | msg1 <- "Not quite." 105 | msg2 <- "Nice job!" 106 | msg3 <- "Keep trying!" 107 | msg4 <- "Nope!" 108 | msg5 <- "Try again!" 109 | 110 | ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5)) 111 | ``` 112 | 113 | --- 114 | 115 | ## Question 3 116 | 117 | ```yaml 118 | type: ExplorableExercise 119 | key: eb6689ed9c 120 | xp: 50 121 | skills: 1 122 | ``` 123 | 124 | Follow the directions in the console to open the R Markdown file. 125 | 126 | You can use the RStudio platform just like you would on your home computer. 127 | 128 | The markdown file contains the instuctions to answer the multiple choice question below. 129 | 130 | Q3. Which of the following best describes the number of girls baptised over the years included in this dataset? 131 | 132 | `@possible_answers` 133 | - There appears to be no trend in the number of girls baptised from 1629 to 1710. 134 | - There is initially an increase in the number of girls baptised, which peaks around 1640. After 1640 there is a decrease in the number of girls baptised, but the number begins to increase again in 1660. Overall the trend is an increase in the number of girls baptised. 135 | - There is initially an increase in the number of girls baptised. This number peaks around 1640 and then after 1640 the number of girls baptised decreases. 136 | - The number of girls baptised has decreased over time. 137 | - There is an initial increase in the number of girls baptised but this number appears to level around 1680 and not change after that time point. 138 | 139 | `@hint` 140 | Check out the instructions in the .Rmd file to answer the multiple choice question. 141 | 142 | `@pre_exercise_code` 143 | ```{r} 144 | # Import the helper file contained in the image 145 | source('/usr/local/lib/R/site-library/run_rstudio.R') 146 | 147 | # Run a new RStudio session and serve it to the user 148 | run_rstudio(1, 3) 149 | 150 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex3.Rprofile 151 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex3.init.R 152 | # lab1_ex3.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex3.Rmd 153 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 154 | ``` 155 | 156 | `@sct` 157 | ```{r,eval=FALSE} 158 | msg1 <- "Try again." 159 | msg2 <- "Awesome!" 160 | msg3 <- "Keep trying!" 161 | msg4 <- "Try again." 162 | msg5 <- "Try again." 163 | 164 | ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5)) 165 | ``` 166 | 167 | --- 168 | 169 | ## Question 4 170 | 171 | ```yaml 172 | type: ExplorableExercise 173 | key: e64497e7f4 174 | xp: 50 175 | skills: 1 176 | ``` 177 | 178 | Follow the directions in the console to open the R Markdown file. 179 | 180 | You can use the RStudio platform just like you would on your home computer. 181 | 182 | The markdown file contains the instuctions to answer the multiple choice question below. 183 | 184 | Q4. How many variables are included in this data set? 185 | 186 | `@possible_answers` 187 | - 2 188 | - 3 189 | - 4 190 | - 74 191 | - 2013 192 | 193 | `@hint` 194 | Check out the instructions in the .Rmd file to answer the multiple choice question. 195 | 196 | `@pre_exercise_code` 197 | ```{r} 198 | # Import the helper file contained in the image 199 | source('/usr/local/lib/R/site-library/run_rstudio.R') 200 | 201 | # Run a new RStudio session and serve it to the user 202 | run_rstudio(1, 4) 203 | 204 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex4.Rprofile 205 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex4.init.R 206 | # lab1_ex4.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex4.Rmd 207 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 208 | ``` 209 | 210 | `@sct` 211 | ```{r,eval=FALSE} 212 | msg1 <- "Try again." 213 | msg2 <- "You got it!" 214 | msg3 <- "Keep trying!" 215 | msg4 <- "Try again." 216 | msg5 <- "Try again." 217 | 218 | ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5)) 219 | ``` 220 | 221 | --- 222 | 223 | ## Question 5 224 | 225 | ```yaml 226 | type: ExplorableExercise 227 | key: b073c8a4d3 228 | xp: 50 229 | skills: 1 230 | ``` 231 | 232 | Follow the directions in the console to open the R Markdown file. 233 | 234 | You can use the RStudio platform just like you would on your home computer. 235 | 236 | The markdown file contains the instuctions to answer the multiple choice question below. 237 | 238 | Q5. Has the proportion of boys born in the US has decreased over time. 239 | 240 | `@possible_answers` 241 | - TRUE 242 | - FALSE 243 | 244 | `@hint` 245 | Check out the instructions in the .Rmd file to answer the multiple choice question. 246 | 247 | `@pre_exercise_code` 248 | ```{r} 249 | # Import the helper file contained in the image 250 | source('/usr/local/lib/R/site-library/run_rstudio.R') 251 | 252 | # Run a new RStudio session and serve it to the user 253 | run_rstudio(1, 5) 254 | 255 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex5.Rprofile 256 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex5.init.R 257 | # lab1_ex5.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex5.Rmd 258 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 259 | ``` 260 | 261 | `@sct` 262 | ```{r,eval=FALSE} 263 | msg1 <- "That's right!" 264 | msg2 <- "Try again." 265 | 266 | ex() %>% check_mc(1, feedback_msgs = c(msg1, msg2)) 267 | ``` 268 | 269 | --- 270 | 271 | ## Question 6 272 | 273 | ```yaml 274 | type: ExplorableExercise 275 | key: 8aee5ae535 276 | xp: 50 277 | skills: 1 278 | ``` 279 | 280 | Follow the directions in the console to open the R Markdown file. 281 | 282 | You can use the RStudio platform just like you would on your home computer. 283 | 284 | The markdown file contains the instuctions to answer the multiple choice question below. 285 | 286 | Q6. Which of the following statements is true? 287 | 288 | `@possible_answers` 289 | - Every year there are more girls born than boys. 290 | - Every year there are more boys born than girls. 291 | - Half of the years there are more boys born, and the other half more girls born. 292 | 293 | `@hint` 294 | Check out the instructions in the .Rmd file to answer the multiple choice question. 295 | 296 | `@pre_exercise_code` 297 | ```{r} 298 | # Import the helper file contained in the image 299 | source('/usr/local/lib/R/site-library/run_rstudio.R') 300 | 301 | # Run a new RStudio session and serve it to the user 302 | run_rstudio(1, 6) 303 | 304 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex6.Rprofile 305 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex6.init.R 306 | # lab1_ex6.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex6.Rmd 307 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 308 | ``` 309 | 310 | `@sct` 311 | ```{r,eval=FALSE} 312 | msg1 <- "Try again." 313 | msg2 <- "Great work!" 314 | msg3 <- "Keep trying!" 315 | ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3)) 316 | ``` 317 | 318 | --- 319 | 320 | ## Question 7 321 | 322 | ```yaml 323 | type: ExplorableExercise 324 | key: 63abfd6950 325 | xp: 50 326 | skills: 1 327 | ``` 328 | 329 | Follow the directions in the console to open the R Markdown file. 330 | 331 | You can use the RStudio platform just like you would on your home computer. 332 | 333 | The markdown file contains the instuctions to answer the multiple choice question below. 334 | 335 | Q7. Which of the following best describes the trend? 336 | 337 | `@possible_answers` 338 | - There appears to be no trend in the boy-to-girl ratio from 1940 to 2013. 339 | - There is initially an increase in boy-to-girl ratio, which peaks around 1960. After 1960 there is a decrease in the boy-to-girl ratio, but the number begins to increase in the mid 1970s. 340 | - There is initially a decrease in the boy-to-girl ratio, and then an increase between 1960 and 1970, followed by a decrease. 341 | - The boy-to-girl ratio has increased over time. 342 | - There is an initial decrease in the boy-to-girl ratio born but this number appears to level around 1960 and remain constant since then. 343 | 344 | `@hint` 345 | Check out the instructions in the .Rmd file to answer the multiple choice question. 346 | 347 | `@pre_exercise_code` 348 | ```{r} 349 | # Import the helper file contained in the image 350 | source('/usr/local/lib/R/site-library/run_rstudio.R') 351 | 352 | # Run a new RStudio session and serve it to the user 353 | run_rstudio(1, 7) 354 | 355 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex7.Rprofile 356 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex7.init.R 357 | # lab1_ex7.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex7.Rmd 358 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 359 | ``` 360 | 361 | `@sct` 362 | ```{r,eval=FALSE} 363 | msg1 <- "Try again." 364 | msg2 <- "Keep trying!" 365 | msg3 <- "Awesome, you did great!" 366 | msg4 <- "Try again." 367 | msg5 <- "Try again." 368 | 369 | ex() %>% check_mc(3, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5)) 370 | ``` 371 | 372 | --- 373 | 374 | ## Question 8 375 | 376 | ```yaml 377 | type: ExplorableExercise 378 | key: ca476ff87f 379 | xp: 50 380 | skills: 1 381 | ``` 382 | 383 | Follow the directions in the console to open the R Markdown file. 384 | 385 | You can use the RStudio platform just like you would on your home computer. 386 | 387 | The markdown file contains the instuctions to answer the multiple choice question below. 388 | 389 | Q8. In what year did we see the most total number of births in the U.S.? 390 | 391 | `@possible_answers` 392 | - 1940 393 | - 1957 394 | - 1961 395 | - 1991 396 | - 2007 397 | 398 | `@hint` 399 | Check out the instructions in the .Rmd file to answer the multiple choice question. 400 | 401 | `@pre_exercise_code` 402 | ```{r} 403 | # Import the helper file contained in the image 404 | source('/usr/local/lib/R/site-library/run_rstudio.R') 405 | 406 | # Run a new RStudio session and serve it to the user 407 | run_rstudio(1, 8) 408 | 409 | # .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex8.Rprofile 410 | # .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex8.init.R 411 | # lab1_ex8.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex8.Rmd 412 | # lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css 413 | # lab8_wk.RData: https://assets.datacamp.com/production/course_1156/datasets/lab8_wk.RData 414 | ``` 415 | 416 | `@sct` 417 | ```{r,eval=FALSE} 418 | msg1 <- "Try again." 419 | msg2 <- "Try again." 420 | msg3 <- "Keep trying!" 421 | msg4 <- "Try again." 422 | msg5 <- "Awesome!" 423 | 424 | ex() %>% check_mc(5, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5)) 425 | success_msg("Click [here](https://assets.datacamp.com/production/repositories/302/datasets/720e84184f8aee15916dd20a19398373827d4b04/ch1_key.Rmd) to get a complete Rmarkdown file of the exercises in this Lab and click [here](https://assets.datacamp.com/production/repositories/302/datasets/9ecc2629166b0b8a841f15a83710ddff282baecc/ch1_key.html) to get the Knitted HTML output.") 426 | ``` 427 | -------------------------------------------------------------------------------- /datasets/ch3_key.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Probability" 3 | output: statsr:::statswithr_lab 4 | --- 5 | 6 | ## Hot Hands 7 | 8 | Basketball players who make several baskets in succession are described as 9 | having a *hot hand*. Fans and players have long believed in the hot hand 10 | phenomenon, which refutes the assumption that each shot is independent of the 11 | next. However, [a 1985 paper](http://www.sciencedirect.com/science/article/pii/0010028585900106) by Gilovich, Vallone, and Tversky collected evidence 12 | that contradicted this belief and showed that successive shots are independent 13 | events. This paper started a great controversy that continues to this day, as you can 14 | see by Googling *hot hand basketball*. 15 | 16 | We do not expect to resolve this controversy today. However, in this lab we'll 17 | apply one approach to answering questions like this. The goals for this lab are 18 | to (1) think about the effects of independent and dependent events, (2) learn 19 | how to simulate shooting streaks in R, and (3) to compare a simulation to actual 20 | data in order to determine if the hot hand phenomenon appears to be real. 21 | 22 | ## Getting Started 23 | 24 | ### Load packages 25 | 26 | In this lab we will explore the data using the `dplyr` package and visualize it 27 | using the `ggplot2` package for data visualization. The data can be found in the 28 | companion package for this course, `statsr`. 29 | 30 | Let's load the packages. 31 | 32 | ```{r load-packages, message=FALSE} 33 | library(statsr) 34 | library(dplyr) 35 | library(ggplot2) 36 | ``` 37 | 38 | ### Data 39 | 40 | Our investigation will focus on the performance of one player: Kobe Bryant of 41 | the Los Angeles Lakers. His performance against the Orlando Magic in the 2009 42 | NBA finals earned him the title *Most Valuable Player* and many spectators 43 | commented on how he appeared to show a hot hand. Let's load some necessary files 44 | that we will need for this lab. 45 | 46 | ```{r load-data} 47 | data(kobe_basket) 48 | ``` 49 | 50 | This data frame contains 133 observations and 6 variables, where every 51 | row records a shot taken by Kobe Bryant. The `shot` variable in this dataset 52 | indicates whether the shot was a hit (`H`) or a miss (`M`). 53 | 54 | Just looking at the string of hits and misses, it can be difficult to gauge 55 | whether or not it seems like Kobe was shooting with a hot hand. One way we can 56 | approach this is by considering the belief that hot hand shooters tend to go on 57 | shooting streaks. For this lab, we define the length of a shooting streak to be 58 | the *number of consecutive baskets made until a miss occurs*. 59 | 60 | For example, in Game 1 Kobe had the following sequence of hits and misses from 61 | his nine shot attempts in the first quarter: 62 | 63 | \[ \textrm{H M | M | H H M | M | M | M} \] 64 | 65 | You can verify this by viewing the first 8 rows of the data in the data viewer. 66 | 67 | Within the nine shot attempts, there are six streaks, which are separated by a 68 | "|" above. Their lengths are one, zero, two, zero, zero, zero (in order of 69 | occurrence). 70 | 71 | 1. Fill in the blank: A streak length of 1 means one \_\_\_ followed by one miss. 72 |
    73 |
  1. hit **- CORRECT ANSWER**
  2. 74 |
  3. miss
  4. 75 |
76 | 77 | 78 | 2. Fill in the blank: A streak length of 0 means one \_\_\_ which must occur after a 79 | miss that ended the preceeding streak. 80 |
    81 |
  1. hit
  2. 82 |
  3. miss **- CORRECT ANSWER**
  4. 83 |
84 | 85 | Counting streak lengths manually for all 133 shots would get tedious, so we'll 86 | use the custom function `calc_streak` to calculate them, and store the results 87 | in a data frame called `kobe_streak` as the `length` variable. 88 | 89 | ```{r calc-streak-kobe} 90 | kobe_streak <- calc_streak(kobe_basket$shot) 91 | ``` 92 | 93 | We can then take a look at the distribution of these streak lengths. 94 | 95 | ```{r plot-streak-kobe} 96 | ggplot(data = kobe_streak, aes(x = length)) + 97 | geom_histogram(binwidth = 1) 98 | ``` 99 | 100 | 3. Which of the following is false about the distribution of Kobe's streak lengths 101 | from the 2009 NBA finals. 102 |
    103 |
  1. The distribution of Kobe's streaks is unimodal and right skewed.
  2. 104 |
  3. The typical length of a streak is 0 since the median of the distribution is at 0.
  4. 105 |
  5. The IQR of the distribution is 1. 106 |
  6. The longest streak of baskets is of length 4.
  7. 107 |
  8. The shortest streak is of length 1.**- CORRECT ANSWER**
  9. 108 |
109 | 110 | ## Compared to What? 111 | 112 | We've shown that Kobe had some long shooting streaks, but are they long enough 113 | to support the belief that he had hot hands? What can we compare them to? 114 | 115 | To answer these questions, let's return to the idea of *independence*. Two 116 | processes are independent if the outcome of one process doesn't effect the outcome 117 | of the second. If each shot that a player takes is an independent process, 118 | having made or missed your first shot will not affect the probability that you 119 | will make or miss your second shot. 120 | 121 | A shooter with a hot hand will have shots that are *not* independent of one 122 | another. Specifically, if the shooter makes his first shot, the hot hand model 123 | says he will have a *higher* probability of making his second shot. 124 | 125 | Let's suppose for a moment that the hot hand model is valid for Kobe. During his 126 | career, the percentage of time Kobe makes a basket (i.e. his shooting 127 | percentage) is about 45%, or in probability notation, 128 | 129 | \[ P(\textrm{shot 1 = H}) = 0.45 \] 130 | 131 | If he makes the first shot and has a hot hand (*not* independent shots), then 132 | the probability that he makes his second shot would go up to, let's say, 60%, 133 | 134 | \[ P(\textrm{shot 2 = H} \, | \, \textrm{shot 1 = H}) = 0.60 \] 135 | 136 | As a result of these increased probabilites, you'd expect Kobe to have longer 137 | streaks. Compare this to the skeptical perspective where Kobe does *not* have a 138 | hot hand, where each shot is independent of the next. If he hit his first shot, 139 | the probability that he makes the second is still 0.45. 140 | 141 | \[ P(\textrm{shot 2 = H} \, | \, \textrm{shot 1 = H}) = 0.45 \] 142 | 143 | In other words, making the first shot did nothing to effect the probability that 144 | he'd make his second shot. If Kobe's shots are independent, then he'd have the 145 | same probability of hitting every shot regardless of his past shots: 45%. 146 | 147 | Now that we've phrased the situation in terms of independent shots, let's return 148 | to the question: how do we tell if Kobe's shooting streaks are long enough to 149 | indicate that he has hot hands? We can compare his streak lengths to someone 150 | without hot hands: an independent shooter. 151 | 152 | ## Simulations in R 153 | 154 | While we don't have any data from a shooter we know to have independent shots, 155 | that sort of data is very easy to simulate in R. In a simulation, you set the 156 | ground rules of a random process and then the computer uses random numbers to 157 | generate an outcome that adheres to those rules. As a simple example, you can 158 | simulate flipping a fair coin with the following. 159 | 160 | ```{r head-tail} 161 | coin_outcomes <- c("heads", "tails") 162 | sample(coin_outcomes, size = 1, replace = TRUE) 163 | ``` 164 | 165 | The vector `outcomes` can be thought of as a hat with two slips of paper in it: 166 | one slip says `heads` and the other says `tails`. The function `sample` draws 167 | one slip from the hat and tells us if it was a head or a tail. 168 | 169 | Run the second command listed above several times. Just like when flipping a 170 | coin, sometimes you'll get a heads, sometimes you'll get a tails, but in the 171 | long run, you'd expect to get roughly equal numbers of each. 172 | 173 | If you wanted to simulate flipping a fair coin 100 times, you could either run 174 | the function 100 times or, more simply, adjust the `size` argument, which 175 | governs how many samples to draw (the `replace = TRUE` argument indicates we put 176 | the slip of paper back in the hat before drawing again). Save the resulting 177 | vector of heads and tails in a new object called `sim_fair_coin`. 178 | 179 | ```{r sim-fair-coin} 180 | sim_fair_coin <- sample(coin_outcomes, size = 100, replace = TRUE) 181 | ``` 182 | 183 | To view the results of this simulation, type the name of the object and then use 184 | `table` to count up the number of heads and tails. 185 | 186 | ```{r table-sim-fair-coin} 187 | sim_fair_coin 188 | table(sim_fair_coin) 189 | ``` 190 | 191 | Since there are only two elements in `outcomes`, the probability that we "flip" 192 | a coin and it lands heads is 0.5. Say we're trying to simulate an unfair coin 193 | that we know only lands heads 20% of the time. We can adjust for this by adding 194 | an argument called `prob`, which provides a vector of two probability weights. 195 | 196 | ```{r sim-unfair-coin} 197 | sim_unfair_coin <- sample(coin_outcomes, size = 100, replace = TRUE, 198 | prob = c(0.2, 0.8)) 199 | ``` 200 | 201 | `prob = c(0.2, 0.8)` indicates that for the two elements in the `outcomes` vector, 202 | we want to select the first one, `heads`, with probability 0.2 and the second 203 | one, `tails` with probability 0.8. Another way of thinking about this is to 204 | think of the outcome space as a bag of 10 chips, where 2 chips are labeled 205 | "head" and 8 chips "tail". Therefore at each draw, the probability of drawing a 206 | chip that says "head"" is 20%, and "tail" is 80%. 207 | 208 |
209 | **Exercise**: In your simulation of flipping the unfair coin 100 times, how many flips came up heads? 210 |
211 | 212 | In a sense, we've shrunken the size of the slip of paper that says "heads", 213 | making it less likely to be drawn and we've increased the size of the slip of 214 | paper saying "tails", making it more likely to be drawn. When we simulated the 215 | fair coin, both slips of paper were the same size. This happens by default if 216 | you don't provide a `prob` argument; all elements in the `outcomes` vector have 217 | an equal probability of being drawn. 218 | 219 | If you want to learn more about `sample` or any other function, recall that you 220 | can always check out its help file with `?sample`. 221 | 222 | 223 | ## Simulating the Independent Shooter 224 | 225 | Simulating a basketball player who has independent shots uses the same mechanism 226 | that we use to simulate a coin flip. To simulate a single shot from an 227 | independent shooter with a shooting percentage of 50% we type, 228 | 229 | ```{r sim-basket} 230 | shot_outcomes <- c("H", "M") 231 | sim_basket <- sample(shot_outcomes, size = 1, replace = TRUE) 232 | ``` 233 | 234 | To make a valid comparison between Kobe and our simulated independent shooter, 235 | we need to align both their shooting percentage and the number of attempted shots. 236 | 237 | 238 |
239 | **Exercise**: What change needs to be made to the `sample` function so that it reflects a shooting percentage of 45%? Make this adjustment, then run a simulation to sample 133 shots. Assign the output of this simulation to a new object called `sim_basket`. 240 | ```{r} 241 | sim_basket <- sample(shot_outcomes, size = 133, replace = TRUE, 242 | prob = c(0.45, 0.55)) 243 | ``` 244 |
245 | 246 | 247 | Note that we've named the new vector `sim_basket`, the same name that we gave to 248 | the previous vector reflecting a shooting percentage of 50%. In this situation, 249 | R overwrites the old object with the new one, so always make sure that you don't 250 | need the information in an old vector before reassigning its name. 251 | 252 | With the results of the simulation saved as `sim_basket`, we have the data 253 | necessary to compare Kobe to our independent shooter. 254 | 255 | Both data sets represent the results of 133 shot attempts, each with the same 256 | shooting percentage of 45%. We know that our simulated data is from a shooter 257 | that has independent shots. That is, we know the simulated shooter does not have 258 | a hot hand. 259 | 260 | ### Comparing Kobe Bryant to the Independent Shooter 261 | 262 |
263 | **Exercise**: Using `calc_streak`, compute the streak lengths of `sim_basket`, and save the results in a data frame called `sim_streak`. Note that since the `sim_streak` object is just a vector and not a variable in a data frame, we don't need to first select it from a data frame like we did earlier when we calculated the streak lengths for Kobe's shots. 264 | ```{r sim-streak-lengths} 265 | sim_streak <- calc_streak(sim_basket) 266 | ``` 267 |
268 | 269 |
270 | **Exercise**: Make a plot of the distribution of simulated streak lengths of the independent shooter. What is the typical streak length for this simulated independent shooter with a 45% shooting percentage? How long is the player's longest streak of baskets in 133 shots? 271 | ```{r plot-sim-streaks} 272 | ggplot(data = sim_streak, aes(x = length)) + 273 | geom_histogram(binwidth = 1) 274 | ``` 275 |
276 | 277 | 4. If you were to run the simulation of the independent shooter a second time, how 278 | would you expect its streak distribution to compare to the distribution from the 279 | exercise above? 280 |
    281 |
  1. Exactly the same
  2. 282 |
  3. Somewhat similar **- CORRECT ANSWER**
  4. 283 |
  5. Totally different
  6. 284 |
285 | 286 | 287 | 5. How does Kobe Bryant's distribution of streak lengths compare to the distribution 288 | of streak lengths for the simulated shooter? Using this comparison, do you have 289 | evidence that the hot hand model fits Kobe's shooting patterns? 290 |
    291 |
  1. The distributions look very similar. Therefore, there doesn't appear to be evidence for Kobe Bryant's hot hand. **- CORRECT ANSWER**
  2. 292 |
  3. The distributions look very similar. Therefore, there appears to be evidence for Kobe Bryant's hot hand.
  4. 293 |
  5. The distributions look very different. Therefore, there doesn't appear to be evidence for Kobe Bryant's hot hand.
  6. 294 |
  7. The distributions look very different. Therefore, there appears to be evidence for Kobe Bryant's hot hand.
  8. 295 |
296 | 297 |
298 | **Exercise**: What concepts from the course videos are covered in this lab? What 299 | concepts, if any, are not covered in the videos? Have you seen these concepts 300 | elsewhere, e.g. textbook, previous labs, or practice problems? 301 |
302 | 303 |
304 | This is a derivative of an [OpenIntro](https://www.openintro.org/stat/labs.php) lab, and is released under a [Attribution-NonCommercial-ShareAlike 3.0 United States](https://creativecommons.org/licenses/by-nc-sa/3.0/us/) license. 305 |
--------------------------------------------------------------------------------