[SOLVED] R game Java javascript theory You need to have JavaScript enabled in order to access this site.

$25

File Name: R_game_Java_javascript_theory_You_need_to_have_JavaScript_enabled_in_order_to_access_this_site..zip
File Size: 894.9 KB

5/5 - (1 vote)

You need to have JavaScript enabled in order to access this site.

Skip To Content
Dashboard
Account
Dashboard
Courses
Groups
Calendar
Inbox
Help

Close
My Dashboard
COMM 205 101 102 103
Quizzes
Part B Assignment 4 (R and RStudio)

2019W1
Home
Announcements
Modules
Discussions
iClicker
Quizzes
Assignments
Grades
Course Evaluation
Piazza
Part B Assignment 4 (R and RStudio)
Started: Nov 30 at 9:47am
Quiz Instructions

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
CASE 1: USE THIS CASE TO ANSWER QUESTIONS 1 THROUGH 4
Suppose that you have the following two datasets covering movies and actors (representative screenshots were provided below). Note that actors will refer both to actors and actresses. You are not provided with the datasets in this case. Please use the description provided below to answer the questions.
Movies data frame
There are exactly 17,454 observations in this data frame, covering all movies released in the US from 1980 to 2014. The unique identifiers for each observation are title and 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 Picture, and 0 otherwise (numerical)

Actors
This data frame contains more than 100,000 observations, covering all actors that had above the line roles in Movies data frame. Above the line credits are the names that appear one by one on the screen during the opening (or sometimes closing) credits for a film. The unique identifiers for each observation are actor_ID, title, and year. Hence, it is possible that the same actor appears multiple times in this dataset because actor_ID by itself is not the unique identifier of this dataset. All observations in Actors data frame can be matched to Movies data frame. This dataset contains the 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 film, and 0 otherwise (numerical)
best_actress: Equals 1 if received the Academy Award for Best Actress for that film, and 0 otherwise (numerical)

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

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 1 8 pts
Suppose you want to identify how many movies in our entireMoviesdata frame each director (bydirector_ID) has directed. You do not want to create a newdata frame with the result. You just want to display the result. Remember thattidyverse library has been already loaded.
Complete the following code that will accomplish the above objective.
Movies %>%
group_by (director_ID) %>%
summarise (number_of_movies = n )

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 2 10 pts
Suppose you want to identify those actors/actresses who have appearedonlyin movies that lost money (where therevenueis less than thebudget). In other words,allthe movies that an actor/actress starred in must be loss-generating movies (i.e., revenue < budget) to be included in the result. If there is even just one movie that made profit or was on a break-evenpoint (i.e., revenue >= budget) among all the movies an actor/actress played, that actor/actress should not be included in the result.
Along with theactor_ID, you want your final data frame to display thetitleandyearofeach movie he/she appeared, amount of money lost in the movie (actual_money_lost, where it is defined asbudget-revenue). Assume thatActorsand Moviesare in your active R session and tidyverse was loaded.
Complete the following code that will accomplish the above objectives. Note that for each blank, you can use the name of an appropriate function or the name of an appropriate variable (i.e., a column name).
Movies2 <- Movies %>%
mutate(lost_money = if_else (revenue < budget, 1, 0))combined <- select (Actors, Movies2)results <- combined %>%
( ) %>%
(at_least_one = ( )) %>%
(at_least_one == 1) %>%
mutate (actual_money_lost = budget revenue) %>%
select(actor_ID, title, year, actual_money_lost)

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 3 8 pts
In 1994, aparlourgame called Six Degrees of Kevin Bacon took off. It requires players to link celebrities to Kevin Bacon in as few steps as possible. Kevin Bacon has appeared in more than 70 movies of varying genres across manyyearssuchasFootlooseandApollo 13and so, the theory is that he is, quite possibly, at the center of the entertainment universe. If you search an actors name in Google followed by Bacon number you 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 filmSleepers.
Will Smiths Bacon number is 2. Will Smith has not appeared in a movie with Kevin Bacon. However, Will Smith andZoKravitzappeared inAfter Earth.ZoKravitzand Kevin Bacon appeared inX-Men: First Class.
Incidentally, although hedoesntappear in Actors, PresidentBarackObamahas a Bacon number of 2. PresidentObamaappeared in the documentaryThe RoadWeveTraveledwith Tom Hanks. Tom Hanks and Kevin Bacon appeared inApollo 13.
You have decided to create a Bacon number for all actors in theActorsdata frame.
As a first step, you want to create a new variable, calledbacon.The variablebaconshould be equal to 1 ifactor_IDis equal to10000001(Kevin Bacons actor_ID), and 0 otherwise. Below are a series of commands that has been started for you.
Complete the followingR code that will allow you to achieve this objective: That is, you will create a new variablebacon, which is equal to 1 ifactor_IDis equal to10000001(Kevin Bacons actor ID), and 0 otherwise. Assume you haveActorsdata frame in your active R session and tidyverse is already loaded.
Actors <- Actors %>%
mutate (bacon = if_else ( actor_ID = 10000001, 1 , 0)

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 4 10 pts
Assume that you have created the variablebaconcorrectly (from the previous question). You want to create a variable, calledbacon_number, which is equal to 1 for all actors that have ever appeared in a movie with Kevin Bacon inActorsdata frame. You wantbacon_numberto be equal to 0 for Kevin Bacon, and you want it to be equal to NA for any other observations.
For example, Tom Cruise appeared with Kevin Bacon in the 1992 movieA Few Good Men, making Tom Cruises Bacon Number equal to 1. We wantbacon_numberto be equal to 1 for all observations for Tom Cruise, even in movies where he did not appear together with Kevin Bacon. For example, we would want to make sure that Tom Cruisesbacon_numberis still equal to 1 when he appears inRain Manin 1988 orEdge of Tomorrowin 2014.
Recall the assumption that you have created the variablebaconsuccessfully before. The following sequence of commands comes right after the previous question. That is, in yourActorsdata frame you have the 7th column calledbaconand it is equal to1for every observations of Kevin Bacon and0otherwise.Also, recall that Kevin Baconsactor_IDis10000001.
Which of the following series of commands will achieve the above task?
There isAT LEAST ONEcorrect option, but youMUST SELECT ALLcorrect option(s). There is no partial credit.
Note that if you put a negative sign (i.e., -) in front of a column name you specified in select(), it means that you want to select all the columns except the one indicated with a negative sign. For example, Actors %>% select(-best_actor) is identical to Actors %>% select( actor_ID, actor_l, actor_f, title, year, best_actress).
Group of answer choices
bacon_temp <-Actors %>%group_by(title, year) %>%summarize(bacon_number_temp = max(bacon))
data_temp <- left_join(Actors, bacon_temp)data_temp2 <- data_temp %>% group_by(actor_ID) %>% summarize(bacon_number = max(bacon_number_temp))
Actors <- left_join(data_temp, data_temp2)Actors$bacon_number[Actors$bacon_number == 0] <- NAActors$bacon_number[Actors$actor_ID == 10000001] <- 0Actors <- Actors %>% select(-bacon_number_temp)
bacon_temp <-Actors%>%group_by(title,year)%>%mutate(bacon_number_temp = max(bacon))
data_temp <- left_join(Actors, bacon_temp)data_temp2 <- data_temp %>% group_by(actor_ID) %>% mutate(bacon_number = max(bacon_number_temp))
Actors <- left_join(data_temp, data_temp2)Actors$bacon_number[Actors$bacon_number == 0] <- NAActors$bacon_number[Actors$actor_ID == 10000001] <- 0Actors <- Actors %>% select(-bacon_number_temp)
Actors <-Actors%>%group_by(title,year)%>%summarize(bacon_number_temp = max(bacon))
Actors <- Actors %>% group_by(actor_ID) %>% summarize(bacon_number = max(bacon_number_temp))
Actors$bacon_number[Actors$bacon_number == 0] <- NAActors$bacon_number[Actors$actor_ID == 10000001] <- 0Actors <- Actors %>% select(-bacon_number_temp)
Actors<-Actors%>%group_by(title,year)%>%mutate(bacon_number_temp=max(bacon))
Actors<-Actors%>%group_by(actor_ID)%>%mutate(bacon_number=max(bacon_number_temp))
Actors$bacon_number[Actors$bacon_number==0]<-NAActors$bacon_number[Actors$actor_ID==10000001]<-0Actors<-Actors%>%select(-bacon_number_temp)
All of the options are incorrect.

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
CASE 2: USE THIS CASE AND THE DATASET (mobile.rds) TO ANSWER QUESTIONS 5 THROUGH 8
The dataset contains data on a select number of mobile apps. Many apps request permissions to access user data or device data. The dataset in mobile.rds list each of the permissions requested by a set of apps.
You need to download mobile.rds and use to answer Questions 5, 6, 7, and 8 of this assignment.
mobile.rds has 524 rows and 4 columns. Each observation (i.e., row) is a particular permission requested by the app indicated in that row. The four columns (with their data types in the parenthesis) are:
App_Type (character): The category of the app. Apps are categorized into a set of app types. Each app belongs to one.
Name (character): The name of the app.
Permission (character): The name of the permission requested by the app.
Permission_Type (character): The category of the permission. Each permission belongs to only one permission type.
If an app requests multiple permissions, there are that many rows for the app in the dataset. Therefore, each observation is uniquely identified by Name and Permission.
When you save the mobile.rds in your working directory, you can load the data as follows.
mobile <- readRDS(“mobile.rds”)Move To… This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question. Flag this QuestionQuestion 5 8 pts You are interested in identifying the app that requests the largest number of permissionsfrom its mobile users?The name of the app that requests the greatest number of permissions is .How many permissions does that app request? Move To… This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question. Flag this QuestionQuestion 6 8 pts How many different (unique) permissions are there in our data set? There are two permissions requested by the greatest number of different apps. Create a new data frame (let’s called it as df) which will list those two permissions in the first column(named as Permission) and the number of apps which request them in the second column (named as num_app).df should look like this:Please complete the code that would create df?df <- mobile %>% group_by( permission ) %>% summarise (num_app = n ()) %>% filter(num_app == (num_app))

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 7 8 pts
Please use mobile data frame loaded from the rds file and df data frame created in Q6 (also shown in the screenshot above). You are interested in creating a new data frame that would list the names of the apps which request the two permissions indentified in Q6. Please complete the following code to createthe data frame of interest.
dfq7 <- (mobile, df) %>% group_by(Name) %>% (requested = if_else(max(num_app, na.rm = TRUE)>0, , )) %>% filter(requested) %>% select(- )

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 8 8 pts
Permissions are categorized into permission types (Permission_Type columnn).
What is the number of different permission types?
What is the permission type which has the smallest number of permissions associated with it? Please complete the code to find that category?
mobile %>% group_by( ) %>% (number_permission = n ()) %>% filter(number_permission == (number_permission))

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
CASE 3: USE THIS CASE AND THE TWO DATASETS(Games.rds AND Players.rds) TO ANSWER QUESTIONS 9 THROUGH 12
The attached datasets contain data on players and games on the most recent two weeks of the National Basketball Association (NBA) games.
There are two datasets that you need to download (Games.rds and Player.rds) and use to 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 observation (a row) represents a player in a particular game. The dataset contains the following variables:
player_id (character): A randomly assigned combination of letter and number that identifies an NBA player.
game_id (character): The three or four letters that precede the @ sign denotes the abbreviation for the away team that is playing at the home of another team. The abbreviation for the home team is the three or four letters that come after the @ sign. For example, chi@den means that chi (Chicago Bulls) is the away team that is playing at the home of den (Denver Nuggets). In this dataset; the placement of the team names in the game_id variable matters; for example, chi@den is treated as a different and separate game from den@chi. Furthermore, there can only be one game for each of team1@team2 combinations; for example, there can only be one game for chi@den.
pts (numerical): Points scored by the player in this game. A player earns two or three points for every basket made.
reb (numerical): The number of rebounds the player achieved in this game. A player earns a rebound for gaining possession of a missed shot after it bounces off the backboard or basketball rim.
ast (numerical): The number of assists that the player made in this game. A player earns an assist for every pass made leading to a basket made.
to (numerical): The number of turnovers the player committed in this game. A player commits a turnover when he/she loses possession of the ball to the opposing team.
Players.rds
The Games.rds dataset contains the following variables:
player_id (character): A randomly assigned combination of letter and number that identifies 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.

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 9 8 pts
Load the datasets into your R session. Now you haveGamesdata frame (loaded from Games.rds) andPlayersdata frame (loaded from Players.rds) in your R session.
You want to merge these two datasets. For these two datasets, whether you use inner_join() or left_join(), the merge datasets would have the same number of rows.

[ Select ]

[TRUE, FALSE, Not enough information to answer the question]

Suppose you had successfully merged the two datasets. player_id variable alone can uniquely identify each observation the merged dataset?

[ Select ]

[TRUE, FALSE, Not enough information to answer the question]

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 10 8 pts
The NBA Most Valuable Player (MVP) award is an annual award given to the best performing player of the regular season in the NBA. Based on two weeks of NBA action in the month of November, the NBA has already considered six (6) MVP candidates (refer to the attached Players.rdsand Games.rdsdatasets). Based on previous years, players winning the award had averaged at least 23 points (pts) per game, averagedat least 5 rebounds (reb) a game, averagedat least 5 assists (ast) a game, and averagedat most 5 turnovers (to) a game.
Based only on the above criteria, how many player(s) is/are on track to win this award? That, how many player(s) satisfy all the criteria. Type the NUMBER only.

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 11 8 pts
The criteria provided in the previous question are based on historical data. In fact, there are no such requirements to winning the MVP award. Rather, the player who accumulates thehighest game scoresthroughout the NBA season will win the award.
Eachplayer earns a game score ineverygame in which he participated.
For the purposes of this question (that is, todetermine a playersgame score in each game), every 1 point (pts) translates to a score of 1; every 1 rebound (reb) translates to a score of 2, every 1 assist (ast) translates to a score of 2, and every turnover (to) translates to a score ofnegative3. Notice that a point isNOTnecessarily the same as a score.
Which player had the highest gamescore(NOT points) in aSINGLEgame? Provide theLAST NAMEof that playerONLY. (Do not use quotations)
What was thegame scoreobtained by the player you identified in that single game? Enter theNUMBERonly.

Move To This element is a more accessible alternative to drag & drop reordering. Press Enter or Space to move this question.
Flag this Question
Question 12 8 pts
Instead of calculating a players game score in each game, we now want you to calculate each players total 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 game,every 1 point (pts) translates to a score of 1; every 1 rebound (reb) translates to a score of 2, every 1 assist (ast) translates to a score of 2, and every turnover (to) translates to a score ofnegative3. Notice that a point isNOTnecessarilythe same as a score.
Which player had the highestaccumulatedgamescores (NOT points) in all the games he had participated? Provide the LAST NAME of that player ONLY. (Do not use quotationmarks)
What was the total (accumulated) game scores obtained by that player? Enter the NUMBER only.

Quiz saved at 4:48pm Submit Quiz
You have been logged out of canvas.
To continue please log in
Questions
Havent Answered YetSpacer
AnsweredQuestion 1
AnsweredQuestion 2
AnsweredQuestion 3
AnsweredQuestion 4
Havent Answered YetSpacer
Havent Answered YetQuestion 5
Havent Answered YetQuestion 6
Havent Answered YetQuestion 7
Havent Answered YetQuestion 8
Havent Answered YetSpacer
AnsweredQuestion 9
Havent Answered YetQuestion 10
Havent Answered YetQuestion 11
Havent Answered YetQuestion 12
Time Elapsed:
Attempt due: Dec 10 at 1am

8 Days, 4 Hours, 0 Minutes, 29 Seconds

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] R game Java javascript theory You need to have JavaScript enabled in order to access this site.
$25