Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / In this lab you will use the plot () function

In this lab you will use the plot () function

Statistics

In this lab you will use the plot () function. Use the Teams dataset from the Lahman package.

We would like to know whether offense or defense is a better predictor or a successful season. We will use the Hits variable to measure offensive power, the Earned Runs Average (ERA) to represent defense, and Wins to measure total games won in a season.

  1. Drop all of the data before 1990.

 

  1. Examine the relationship between Hits and Wins using a scatterplot. Use meaningful labels and a visually appealing style.

 

  1. Annotate two outliers on the graph with the teamID. You can identify the points using the identify function and clicking on the graph near the points to return their positions:

              identify (x, y)

     
  2. Examine the relationship between ERA and Wins using a scatterplot. Use meaningful labels and a visually appealing style.

 

  1. Annotate two outliers on the graph with the teamID.

 

  1. BONUS – add a trend line to the scatterplot to highlight the relationship.
     

Submit your result as a PDF or HTML document. You will need to “knit” your.rmd file first.           

 

 

 

Two hints:

 

To label points, you can use the identify() or locator() functions to find specific points. 

 

 

Note that identify() requires the x-y variables as arguments, whereas locator() does not require arguments. Identify will return the row position of your data, which you can then use to subset your positions and labels:

 

text (x=dat$H[c(3,17)], y=dat$W [c(3,17)], labels=dat$teamID[c(3,17)] )

 

 

When knitting, you will need to include both a plot () function and a text () function in the SAME chunk of code, otherwise you will get an error.

 

 

 

Option 1

Low Cost Option
Download this past answer in few clicks

15.98 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE