Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer in R Language Answer the following questions in either R (preferre

ID: 3851350 • Letter: P

Question

Please answer in R Language

Answer the following questions in either R (preferred) or Python. If you choose to use Python, you will have to use R to save the data and then read into Python. Using Lahman MLB data in R, list the top 5 teams since 2000 with the largest stolen bases per at bat ratio: library (Lahman) head (Batting) > library (Lahman) +head (Batting) + where each row represents the yearly statistics for a player on a team in a year. Here, G = games played by the player, AB = at bats.

Explanation / Answer

#1.Using Lahman MLB data in R, list the top 5 teams since 2000 with the largest stolen bases per at bat ratio: # Ans: using the Team data #also there were some team name changes so, need to reflect that i.e. 30 baseball teams + Montreal Expos was dropped = 31 mydata = Teams %>% select(yearID, name, SB, AB, teamID) %>% filter(yearID>= 2000)%>% filter(!is.na(SB)) %>% filter(!is.na(AB)) %>% mutate(name = ifelse(name == "Tampa Bay Devil Rays", "Tampa Bay Rays", name)) %>% mutate(name = ifelse(name == "Anaheim Angels", "Los Angeles Angels of Anaheim", name)) %>% mutate(name = ifelse(name == "Florida Marlins", "Miami Marlins", name)) %>% group_by(name) %>% summarise(SB = sum(SB), AB = sum(AB)) %>% mutate(sbpab = SB/AB) %>% arrange(desc(sbpab)) head(mydata %>% select(name),5) #head(Batting)