100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

DSCI Tutorial 1 - Intro_solution (2022)

Rating
-
Sold
-
Pages
12
Uploaded on
11-04-2022
Written in
2021/2022

dsci 100 tutorial 1 - intro_solution










Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
April 11, 2022
Number of pages
12
Written in
2021/2022
Type
Class notes
Professor(s)
Jack davis
Contains
All classes

Subjects

Content preview

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.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
travissmith1 UBC
View profile
Follow You need to be logged in order to follow users or courses
Sold
97
Member since
4 year
Number of followers
61
Documents
36
Last sold
1 month ago

3.6

16 reviews

5
6
4
6
3
0
2
0
1
4

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions