Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

In this lab you will use the plot () function

Statistics Nov 30, 2020

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.

 

 

 

Expert Solution

Buy This Solution
15.98 USD
Instant Access
Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get a fresh solution
Get Custom Quote
Secure Payment