Question: i just need the commands for #5 using R Question 5 The objective of this question is to give practice with using vectorization with factors.

i just need the commands for #5 using R

i just need the commands for #5 using R Question 5 The

Question 5 The objective of this question is to give practice with using vectorization with factors. Download the mlb . RData1 le from BruinLearn and save it to your working directory. Then run the command loadC"mlb.RData") to load data from the 2018 season of Major League Baseball. This command will create 6 objects in your workspace: league: A factor with 2 levels indicating if the player plays for a team in the American League (AL) or the National League (NL). team: A factor with 30 levels indicating which Major League Baseball team the player is a member of. pea: A factor with 9 levels indicating the primary position of the player. ab: An integer vector indicating the number of "at bats" the player had. hit: An integer vector indicating the number of "hits" the player had. hr: An integer vector indicating the number of "home runs" the player had. Using one command nd the maximum number of hits from each team.. 11. Using one command nd the number of players on each team. 11]. Using one command and no subsetting, nd the number of players on each team with at least one home run. (13} A denition: Batting Average: the batting average of a player (or a team), is calculated by the number of hits (hit) divided by the number of at bats (ab). e 1. Using one command, nd the highest batting average for each team among players with at least 100 at bats. '- 11. Using one command, nd the batting average for each team. (C) Using one command, nd the average number of home runs for each position in each league. Which position has the largest difference between leagues? (d) Using one command, compute the median number of players for each position on any team. 1The data found in m1b.RData was obtained from the Lehman R package in GRAN, with modications

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!