---
title: "ADA1: Class 11, Logarithmic Transformation, intro"
author: "Your Name Here"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output:
html_document:
toc: true
---
# Rubric
Answer the questions in this document, compile to html, print to pdf, and submit to UNM Learn.
Do not add this to your "ALL" `.Rmd` document.
1. (2 p) Read and plot data, with $x$ = `Avg_Mercury` vs $y$ = `Alkalinity`.
2. (1 p) Describe the relationship you see.
3. (4 p) Determine an appropriate transformation of the $x$-variable, $y$-variable, or both
in order to have a straight-line relationship.
* I recommend creating three more plots:
$(\log(x), y)$, $(x,\log(y))$, and $(\log(x), \log(y))$.
Choose the one that, in your view, is best described by a straight line.
* Describe in a sentence what makes this one the best choice.
4. (3 p) Interpret the slope on the transformed scale.
For example, "For each unit increase in [$x$-variable], ..."
---
_Add your answers under the appropriate subsections below, then submit your results to UNM Learn as a pdf file._
## 1. Read and plot data
Save the datafile from the website to your computer.
Read the data.
```{R}
library(tidyverse)
# the "skip = 25" ignores the first 25 lines of the text file (where I put descriptive text)
# and starts reading at line 26.
dat_fish <-
read.table(
"ADA1_CL_11_Data-FishMercury.txt"
, skip = 25
, header = TRUE
)
str(dat_fish)
```
Plot $x$ = `Avg_Mercury` vs $y$ = `Alkalinity` on their natural (original) scales.
## 2. Describe the relationship you see
## 3. Transform and plot
Note, there are two ways to plot the transformed data in `ggplot()`.
Do either of these but not both.
1. Transform variables, plot transformed variables.
2. Plot original variable with rescaled axes.
_(Note: Do not plot transformed variables on scaled axes, since that's like transforming twice: $\log(\log(x))$.)_
```
# With ggplot() consider using these "scale_?_log10()"" commands
# to plot the original variables with scaled axes.
# Compare to plotting the transformed variables directly.
p <- p + scale_x_log10()
p <- p + scale_y_log10()
```
## 4. Interpret slope on the transformed scale