100% Guaranteed Results


STAT GR5206 Homework 3 [40 pts] Solved
$ 24.99
Category:

Description

5/5 – (1 vote)

Your homework should be submitted on Canvas as an R Markdown file. Please submit the knitted .pdf (or .html) file along with the .Rmd file. We will not (and cannot) accept any other formats. Please clearly label the questions in your responses and support your answers by textual explanations and the code you use to produce the result. Note that you cannot answer the questions by observing the data in the “Environment” section of RStudio or in Excel – you must use coded commands.
Goals: regular expressions, character functions in R, and web scraping.
To do this, perform the following tasks:
i. Open the link http://www.espn.com/nba/team/schedule/_/name/BKN/seasontype/ 2. Save the page as NetsSchedule1819 using a .html extension. Once the file is saved, check that you can open the file by a text editor or import it in R.
ii. Use the readLines() command we studied in class to load the NetsSchedule1819.html file into a character vector in R. Call the vector nets1819.
a. How many lines are in the NetsSchedule1819.html file?
b. What is the total number of characters in the file?
c. What is the maximum number of characters in a single line of the file?
iii. Open the webpage. You should see a table listing all the games scheduled for the 20182019 NBA season. There are a total of 82 regular season games scheduled. Who and when are they playing first? Who and when are they playing last?
1
v. Write a regular expression to extract the line that contains the time, location, and opponent of all games.
ix. Use the same strategy as in (vii) and (viii) to create a time vector that stores the time of the game.
x. We would now like to gather information about whether the game is home or away. This information is indicated in the schedule by either an ‘@’ or a ‘vs’ in front of the opponent. If the Nets are playing ‘@’ their opponent’s court, the game is away. If the Nets are playing ‘vs’ the opponent, the game is at home.
HINT: In my solution, I use the fact that in each line, the string <div class=”flex items-center opponent-logo”><span class=”pr2″> appears before this information. So my regular expression searches for that string followed by ‘@’ or that string followed by ‘vs’. After I’ve extracted these strings, I use substring() to finally extract just the ‘@’ or the ‘vs’.
2

Reviews

There are no reviews yet.

Be the first to review “STAT GR5206 Homework 3 [40 pts] Solved”

Your email address will not be published. Required fields are marked *

Related products