Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Install and load the Lahman library. This database includes data related to baseball teams. It includes summary statistics about how the players performed on

1. Install and load the Lahman library. This database includes data related to baseball teams. It includes summary statistics about how the players performed on offense and defense for several years. It also includes personal information about the players.

The Batting data frame contains the offensive statistics for all players for many years. You can see, for example, the top 10 hitters by running this code:

library(Lahman) top <- Batting %>% filter(yearID == 2016) %>% arrange(desc(HR)) %>% slice(1:10) top %>% as_tibble()

But who are these players? We see an ID, but not the names. The player names are in this table

Master %>% as_tibble()

We can see column names nameFirst and nameLast. Use the left_join function to create a table of the top home run hitters. The table should have playerID, first name, last name, and number of home runs (HR). Rewrite the object top with this new table.

2. Now use the Salaries data frame to add each player's salary to the table you created in exercise 1. Note that salaries are different every year so make sure to filter for the year 2016, then use right_join. This time show first name, last name, team, HR, and salary.

I know that I only can post one question but these two questions are related to each other. Thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elementary Algebra

Authors: Charles P McKeague

2nd Edition

1483263819, 9781483263816

More Books

Students also viewed these Mathematics questions

Question

3. Create the categories or equal intervals in an ascending order.

Answered: 1 week ago

Question

Develop skills for building positive relationships.

Answered: 1 week ago

Question

Describe techniques for resolving conflicts.

Answered: 1 week ago

Question

Give feedback effectively and receive it appropriately.

Answered: 1 week ago