--- title: "Module 2, Assignment 1: Scatter Plots" author: "Ellen Bledsoe, Lily McMullen" format: html execute: eval: false --- ```{r} #| include: false knitr::opts_chunk$set(echo = TRUE) ``` # Assignment Details ### Purpose The goal of this assignment is to assess your ability to produce and interpret scatter plots in both base R and `ggplot2`. ### Task Write R code which produces the correct answers and text to correctly interpret the plots produced. ### Criteria for Success - Code is within the provided code chunks - Code chunks run without errors - Code produces the correct result - Code that produces the correct answer will receive full credit - Code attempts with logical direction will receive partial credit - Code used is based on what we have learned in this course - Written answers address the questions in sufficient detail # Assignment Questions For this assignment, we are going to be making plots! We are going to use a data set containing data from a sample of our fish tanks. The data contains information about the tanks sampled and how many sick fish are contained in each tank. Questions are worth 1 point unless otherwise noted. First, let's prepare our data. 1. Load the `tidyverse` package into the work space. ```{r} ``` 2. Read in the data using the `read_csv()` function. Name the data frame `sick_fish`. ```{r} ``` 3. How many rows does the `sick_fish` data frame have? How many columns? *Answer*: 4. Use a function (`head()`, `str()`, or another function you prefer) to take a look at the data points in the data frame. ```{r} ``` 5. What does one row (observation) represent (e.g., an individual fish?, all fish of a certain species? all tanks of a certain species? etc.)? *Answer*: 6. Based on the column names, briefly describe what data is included in the data frame. *Answer:* 7. Take a look at the columns that have the total number of fish in the tank and the number of sick fish per tank. Determine whether these two columns are numeric or categorical. *Answer*: ### Plotting with base R 8. Using *base R* (the code we learned in lesson 2.1), create a histogram of the number of sick fish in each tank. ```{r} ``` 9. In 2-3 sentences, describe what the histogram tells you about the distribution of the number of sick fish. (2 points) *Answer*: 10. Using *base R* (the code we learned in lesson 2.1), create a scatter plot. Put the total number of fish on the x-axis and the number of sick fish on the y-axis. ```{r} ``` 11. Interpret the scatter plot. What is the plot telling you? Is there a positive or negative relationship between the two variables. What does that mean? (2 points) *Answer*: ### Using `ggplot2` Now, let's use what we've learned about `ggplot2` to recreate the same scatter plot. We will do this in 2 steps. - In the first step, we will add the data, axes, and geom. - In the second step, we will modify the plot to increase interpretability by renaming axes and adding a theme. 12. Create the scatter plot using the proper `geom` function. ```{r} ``` 13. Now, recreate the plot from Question 12 and add better axes labels and choose a theme to make it clearer to understand. ```{r} ``` 14. For *each* fish species, calculate the average and the standard deviation for the number of sick fish. *Hint: think back to Module 1 and which function we can use to "split, apply, combine"* ```{r} ``` 15. Based on the summary data you've calculated above, do you think the two clumps of data correspond to the two species? Which species seems to be the one that is causing the most problems? (2 points) *Answer*: 16. Do some brainstorming. Based on the plots we've made and the calculations we've done so far, are we *sure* that the two clumps of data we see in the data visualization do, in fact, correlate to the two different species? How could we confirm? How might we include that information in the plot? (2 points) *Answer*: # Turning in Your Assignment 1. Make sure your name is filled in at the top of the document. 2. Click the **Render** button at the top of this document. This will produce an HTML file that opens in a new tab and also saves to the Files panel on the bottom-right of your screen. 3. To download the HTML file from Posit Cloud, click the empty box to the left of it in the Files panel. 4. Click the blue gear at the top of the Files panel and choose Export. 5. Put your last name at the front of the file name when prompted, then click Download. The file is now in your Downloads folder.