This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
Salaries$salary <- as.numeric(Salaries$salary)
Salaries.AL <- Salaries[Salaries$lgID=="AL" & Salaries$yearID==2002,]
Salaries.NL <- Salaries[Salaries$lgID=="NL" & Salaries$yearID==2002,]
budgets.AL <- tapply(Salaries.AL$salary, Salaries.AL$teamID, sum, na.rm=T)
budgets.NL <- tapply(Salaries.NL$salary, Salaries.NL$teamID, sum, na.rm=T)
AL <- data.frame( budget=budgets.AL, team=names(budgets.AL) )
NL <- data.frame( budget=budgets.NL, team=names(budgets.NL))
budgets.AL <- budgets.AL[!is.na(budgets.AL)]
budgets.NL <- budgets.NL[!is.na(budgets.NL)]
budgets.AL <- c(budgets.AL, "League Average"=mean(budgets.AL))
budgets.NL <- c(budgets.NL, "League Average"=mean(budgets.NL))
budgets.AL <- sort(budgets.AL)
budgets.NL <- sort(budgets.NL)
r <- barplot(budgets.AL, horiz=T,width=c(rep(0.1,8),0.15,rep(0.1,6)),space=c(rep(40,8),60,60,rep(40,5)),col="skyblue",border="skyblue",las=1,axes=F,main="2002 Budgets of Teams in the American League",xlim=c(0,1.1*max(budgets.AL)))...
This is only a preview of the solution. Please use the purchase button to see the entire solution