100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
DSCI Tutorial 1 - Intro_solution (2022) CA$10.46   Add to cart

Class notes

DSCI Tutorial 1 - Intro_solution (2022)

 3 views  0 purchase

dsci 100 tutorial 1 - intro_solution

Preview 2 out of 12  pages

  • April 11, 2022
  • 12
  • 2021/2022
  • Class notes
  • Jack davis
  • All classes
All documents for this subject (1)
avatar-seller
travissmith1
Tutorial 1: Introduction to Data Science
Lecture and Tutorial Learning Goals:
After completing this week's lecture and tutorial work, you will be able to:

use a Jupyter notebook to execute provided R code
edit code and markdown cells in a Jupyter notebook
create new code and markdown cells in a Jupyter notebook
load the tidyverse library into R
create new variables and objects in R using the assignment symbol
use the help and documentation tools in R
match the names of the following functions from the tidyverse library to their documentation descriptions:
read_csv
select
mutate
filter
ggplot
aes

Any place you see ... , you must fill in the function, variable, or data to complete the code. Replace fail() with your completed code and run the
cell!

Reminder: All autograded questions (i.e., questions with tests) are worth 1 point and all hidden test and manually graded questions are worth 3 points.


In [ ]:

### Run this cell before continuing.
library(repr)
options(repr.matrix.max.rows = 6)
source("tests.R")
source("cleanup.R")


Revision Question Match the following definitions with the corresponding functions used in R:
{points: 1}

Definitions

A. Reads the most common types of flat file data, comma separated values.

B. Keeps only the variables you mention.

C. Keeps only rows with entries satisfying some logical condition that you specify.

D. Adds a new variable to a data frame as a function of the old columns.

E. Declares the input data frame for a graphic and specifies the set of plot aesthetics intended to be common throughout all subsequent layers unless
specifically overridden.

Functions

1. ggplot
2. select
3. filter
4. read_csv
5. mutate

For each definition, assign the integer corresponding to the correct function to the letter object associated with the defintion. For example:

B <- 1


Assign your answers to the objects A , B , C , D , and E . Your answers should each be a single integer.

, In [ ]:

# Replace the fail() with your answer.

### BEGIN SOLUTION
E <- 1
B <- 2
A <- 4
D <- 5
C <- 3
### END SOLUTION

In [ ]:

test_revision()



1. Vickers and Vertosick Exercise
We hope you haven't forgotten about them just yet! As you might recall from lecture, Vickers and Vertosick were the researchers that wanted to study
different factors affecting race performance of recreational runners. They assembled a data set that includes the age, sex, and Body Mass Index (BMI) of
runners, comparing it with their timed performance (how long it took them to complete either 5 or 10 km runs).

We will be continuing our analysis of their data to practice what you learnt during the previous lecture. The goal for today, however, is to produce a plot of
BMI against the time (in minutes) it took for participants under the age of 35 to run 5 kilometres. To do this, we will need to complete the following steps:

1. use filter to extract the rows where age is less than 35
2. use select to extract the bmi and km5_time_seconds columns
3. use mutate to convert 5 km race time from seconds ( km5_time_seconds ) to minutes
4. use ggplot to create our plot of BMI (x-axis) and race time in minutes (y-axis)

Tips for success: Try going through all of the steps on your own, but don't forget to discuss with others (classmates, TAs, or an instructor) if you get
stuck. If something is wrong and you can't spot the issue, be sure to read the error message carefully. Since there are a lot of steps involved in working
with data and modifying it, feel free to look back at worksheet_01 (https://github.com/UBC-DSCI/dsci-
100/blob/master/materials/worksheet_01/worksheet_01.ipynb) for assistance.


Question 1.1 Multiple Choice
{points: 1}

After reading the text above (and remembering that filter lets us choose rows that have values at, above, or below a threshold), what column do you
think we will be using for our threshold when we filter?

A. age

B. km5_time_seconds

C. bmi

D. sex

Assign your answer to an object called answer1.1 . Make sure to write the uppercase letter for the answer you have chosen and surround the letter with
quotes.


In [ ]:

# Make sure the correct answer is an uppercase letter.
# Surround your answer with quotation marks.
# Replace the fail() with your answer.

### BEGIN SOLUTION
answer1.1 <- "A"
### END SOLUTION


In [ ]:

test_1.1()


Question 1.2 True or False
{points: 1}

We will be selecting the columns age and km5_time_seconds to plot. True or false?

Assign your answer (of either "true" or "false" ) to an object called answer1.2 . Make sure to write in all lower-case and surround your answer
with quotes.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller travissmith1. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for CA$10.46. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79789 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
CA$10.46
  • (0)
  Add to cart