Quiz Assignment 4 R 2018 W1 Questions answers PDF

Title Quiz Assignment 4 R 2018 W1 Questions answers
Author Rohith Niranjan
Course Introduction to Management Information Systems
Institution The University of British Columbia
Pages 12
File Size 616.4 KB
File Type PDF
Total Downloads 21
Total Views 136

Summary

Assignment answers for comm 205 from 2021. Some of them may be wrong be careful. It is about R and its basic explanation....


Description

Assignment 4 (R) - 2018W1 - Ques!ons Started: Nov 23 at 1am

Quiz Instruc!ons

CASE 1: USE THIS CASE TO ANSWER QUESTIONS 1 THROUGH 4 Suppose that you have the following two datasets covering movies and acto (representative screenshots were provided below). Note that “actors” will re and actresses. You are not provided with the datasets in this case. Please u description provided below to answer the questions. Movies data frame There are exactly 17,454 observations in this data frame, covering all m in the US from 1980 to 2014. The unique identifiers for each observatio year. This dataset contains the following variables (i.e., columns): title: Movie title (character) year: Year of release (numerical) length: Length, in minutes (numerical) director_l: Last name of director (character) director_f: First name of director (character) director_ID: A unique 8-digit number for each director (numerical) budget: Budget, in dollars (numerical) revenue: U.S. Box Office revenue, in dollars (numerical) best_picture: Equals 1 if the movie won the Academy Award for Best Pictu

because actor_ID by itself is not the unique identifier of this dataset. A in Actors data frame can be matched to Movies data frame. This datas following variables (i.e., columns): actor_ID: A unique 8-digit number for each actor (numerical) actor_l: Last name of actor (character) actor_f: First name of actor (character) title: Title of movie that actor appeared in (character) year: Year that movie was released (numerical) best_actor: Equals 1 if received the Academy Award for Best Actor for that otherwise (numerical) best_actress: Equals 1 if received the Academy Award for Best Actress fo otherwise (numerical)

Assume that these two data frames (Movies and Actors) are in your active R Assume there are NO missing values for ANY observations in either datase

Question 1 Suppose you want to identify how many movies in our entire Movies data frame each directo (by director_ID) has directed. You do not want to create a new data frame with the result. Y display the result. Remember that tidyverse library has been already loaded. Complete the following code that will accomplish the above objective.

Question 2 Suppose you want to identify those actors/actresses who have appeared only in movies that the revenue is less than the budget). In other words, all the movies that an actor/actress st loss-generating movies (i.e., revenue < budget) to be included in the result. If there is eve that made profit or was on a break-even point (i.e., revenue >= budget) among all the mo actor/actress played, that actor/actress should not be included in the result. Along with the actor_ID, you want your final data frame to display the title and year of appeared, amount of money lost in the movie (actual_money_lost, where it is defined as Assume that Actors and Movies are in your active R session and tidyverse was loaded. Complete the following code that will accomplish the above objectives. Note that for each bl the name of an appropriate function or the name of an appropriate variable (i.e., a column na Movies2 %

mutate(lost_money =

combined %

group_by

(

actor_ID

summarise

(at_least_one =

) %>%

sum

(

los

Question 3 In 1994, a parlour game called “Six Degrees of Kevin Bacon” took off. It requires players to li Kevin Bacon in as few steps as possible. Kevin Bacon has appeared in more than 70 movies across many years—such as Footloose and Apollo 13—and so, the theory is that he is, quite center of the entertainment universe. If you search an actor’s name in Google followed by “B will get the degrees of separation to get to Kevin Bacon. Kevin Bacon himself has a Bacon number of 0. Brad Pitt has a Bacon number of 1, since they both appeared in the 1996 film Sleepers. Will Smith’s Bacon number is 2. Will Smith has not appeared in a movie with Kevin Bacon. H and Zoë Kravitz appeared in After Earth. Zoë Kravitz and Kevin Bacon appeared in X-Men: F Incidentally, although he doesn’t appear in Actors, President Barack Obama has a Bacon nu President Obama appeared in the documentary The Road We’ve Traveled with Tom Hanks. T Kevin Bacon appeared in Apollo 13. You have decided to create a Bacon number for all actors in the Actors data frame. As a first step, you want to create a new variable, called bacon. The variable bacon should b if actor_ID is equal to 10000001 (Kevin Bacon’s actor_ID), and 0 otherwise. Below are a commands that has been started for you. Complete the following R code that will allow you to achieve this objective: That is, you will c variable bacon, which is equal to 1 if actor_ID is equal to 10000001 (Kevin Bacon’s actor otherwise. Assume you have Actors data frame in your active R session and tidyverse is alr Actors %

mutate ==

(bacon =

10000001,

1

if_else

(

, 0)

actor_ID

Cruise’s bacon_number is still equal to 1 when he appears in Rain Man in 1988 or Edge of T Recall the assumption that you have created the variable bacon successfully before. The fol commands comes right after the previous question. That is, in your Actors data frame you ha called bacon and it is equal to 1 for every observations of Kevin Bacon and 0 otherwise. Als Bacon’s actor_ID is 10000001. Which of the following series of commands will achieve the above task? There is AT LEAST ONE correct option, but you MUST SELECT ALL correct option(s). There Note that if you put a negative sign (i.e., -) in front of a column name you specified in selec you want to select all the columns except the one indicated with a negative sign. For exampl select(-best_actor) is identical to Actors %>% select( actor_ID, actor_l, a year, best_actress).

bacon_temp % group_by(title, year) %>% summarize(bacon_number_temp = max(bacon)) data_temp

% summarize = max(bacon_number_temp)) Actors %

filter(requested) %>% select(- False

)

What is the permission type which has the smallest number of permissions it? Please complete the code to find that category? mobile %>% group_by( permission_type summarise

) %>%

(number_permission = n

filter(number_permission == min

()) %>% (number_permission))

CASE 3: USE THIS CASE AND THE TWO DATASETS (Games.rds AND ANSWER QUESTIONS 9 THROUGH 12 The attached datasets contain data on players and games on the most rece the National Basketball Association (NBA) games. There are two datasets that you need to download (Games.rds and Player answer Questions 9, 10, 11, and 12 of this assignment. You may need to merge the two datasets to answer some of the questions. Games.rds The Games.rds dataset contains key game stats for players. An observatio represents a player in a particular game. The dataset contains the following player_id (character): A randomly assigned combination of letter and num an NBA player. game_id (character): The three or four letters that precede the @ sign den abbreviation for the “away” team that is playing at the “home” of another tea

reb (numerical): The number of rebounds the player achieved in this gam earns a rebound for gaining possession of a missed shot after it bounces o or basketball rim. ast (numerical): The number of assists that the player made in this game an assist for every pass made leading to a basket made. to (numerical): The number of turnovers the player committed in this gam commits a turnover when he/she loses possession of the ball to the oppos Players.rds The Games.rds dataset contains the following variables: player_id (character): A randomly assigned combination of letter and num an NBA player. first_name (character): The first name of an NBA player. last_name (character): The last name of an NBA player. team_name (character): The team represented by the NBA player.

Question 9

Suppose you have Games data frame (loaded from Games.rds) and Players data frame (lo Players.rds) in your R session. You want to merge these two datasets. For these two datasets, whether you use inner_joi left_join(), the merge datasets would have the same number of rows.

TRUE

The NBA Most Valuable Player (MVP) award is an annual award given to th performing player of the regular season in the NBA. Based on two weeks of the month of November, the NBA has already considered six (6) MVP cand the attached Players.rds and Games.rds datasets). Based on previous yea winning the award had averaged at least 23 points (pts) per game, averag rebounds (reb) a game, averaged at least 5 assists (ast) a game, and ave turnovers (to) a game. Based only on the above criteria, how many player(s) is/are on track to win That, how many player(s) satisfy all the criteria. Type the NUMBER only. 6

Question 11 The criteria provided in the previous question are based on historical data. In fact, there are n requirements to winning the MVP award. Rather, the player who accumulates the highest ga scores throughout the NBA season will win the award. Each player earns a game score in every game in which he participated. For the purposes of this question (that is, to determine a player’s game score in each game (pts) translates to a score of 1; every 1 rebound (reb) translates to a score of 2, every 1 assi to a score of 2, and every turnover (to) translates to a score of negative 3. Notice that a poin the same as a score. Which player had the highest game score (NOT points) in a SINGLE game? Provide the LAST player ONLY. (Do not use quotations)

james

What was the game score obtained by the player you identified in that single game? Enter t

68

Instead of calculating a player's game score in each game, we now want you to calculate ea scores across all the games in which he participated. Recall the assumptions used in Question 11, which still apply in in this question. In every gam (pts) translates to a score of 1; every 1 rebound (reb) translates to a score of 2, every 1 assi to a score of 2, and every turnover (to) translates to a score of negative 3. Notice that a poin is NOT necessarily the same as a score. Which player had the highest accumulated game scores (NOT points) in all the games he ha Provide the LAST NAME of that player ONLY. (Do not use quotation marks)

Westbrook

What was the total (accumulated) game scores obtained by that player? Enter the NUMBE

225

Sa...


Similar Free PDFs