2. The data set `MLB-TeamBatting-S16.csv` contains MLB Team Batting Data for selected variables. Load the data...

50.1K

Verified Solution

Question

Basic Math


2. The data set `MLB-TeamBatting-S16.csv` contains MLB Team BattingData for selected variables. Load the data set from the given urlusing the code below. This data set was obtained from [BaseballReference](https://www.baseball-reference.com/leagues/MLB/2016-standard-batting.shtml).
* Tm - Team   
* Lg - League: American League (AL), National League (NL)
* BatAge - Batters’ average age
* RPG - Runs Scored Per Game
* G - Games Played or Pitched
* AB - At Bats
* R - Runs Scored/Allowed
* H - Hits/Hits Allowed
* HR - Home Runs Hit/Allowed
* RBI - Runs Batted In
* SO - Strikeouts
* BA - Hits/At Bats
* SH - Sacrifice Hits (Sacrifice Bunts)
* SF - Sacrifice Flies

Using the `mlb16.data` data, do the following:
i) use `filter` to select teams with the following arguments:
a) Cardinals team `STL`.
b) teams with Hits `H` more than 1400 last 2016 season.  
c) team league `Lg` is National League `NL`.   
ii) use `arrange` to select teams in decreasing number of home runs`HR`.
iii) use `arrange` to display the teams in decreasing number of`RBI`.   
iv) use `group_by` to group the teams per league; and `summarise`to compute the average `RBI` within each league. Use the pipe`%>%` operator to string multiple functions.   
  


### Code chunk
```{r}
# load the data set
mlb16.data <-read.csv("https://raw.githubusercontent.com/jpailden/rstatlab/master/data/MLB-TeamBatting-S16.csv")
str(mlb16.data) # check structure
head(mlb16.data) # show first six rows

# last R code line
```

Answer & Explanation Solved by verified expert
3.7 Ratings (532 Votes)
Code    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students