---
title: 'Laboratory Exercise Week 11'
author: "Your Name and Section, 10 pts"
date: "Todays Date"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

*Directions*: 

* Write your R code inside the code chunks after each question.
* Write your answer comments after the `#` sign.
* To generate the word document output, click the button `Knit` and wait for the word document to appear.
* RStudio will prompt you (only once) to install the `knitr` package.
* Submit your completed laboratory exercise using Blackboard's Turnitin feature. Your Turnitin upload link is found on your Blackboard Course shell under the Laboratory folder.

***

For this exercise, you will need to use the packages `mosaic` and `dplyr` to find numerical and graphical summaries.



```{r warning=FALSE, message=FALSE}
# install packages if necessary
if (!require(mosaic)) install.packages(`mosaic`)
if (!require(dplyr)) install.packages(`dplyr`)
# load the package in R
library(mosaic) # load the package mosaic to use its functions
library(dplyr) # load the package dplyr to use data management functions
```



1. Lactation promotes a temporary loss of bone mass to provide adequate amounts of calcium for milk reproduction. The paper ["Bone Mass is Recovered from Lactation to Postweaning in Adolescent in Adolescent Mothers with Low Calcium Intakes"](https://www.ncbi.nlm.nih.gov/pubmed/15531682) gave the following data on total body bone mineral content (TBBMC) (g) for a sample both during lactation (L) and in the postweaning period (P).  

```{r}
TBBMC <- read.table(header = T, text="
Subject	 Lactation	Postweaning
1	       1928	      2126
2	       2549	      2885
3	       2825	      2895
4	       1924	      1942
5	       1628	      1750
6	       2175	      2184
7	       2114	      2164
8	       2621	      2626
9	       1843	      2006
10	     2541	      2627
")
TBBMC
```

  i) Compute the differences in the TBBMC between "during lactation" and "postweaning period". Assign this new column into the same data set.  
  ii) Compute summary statistics (mean and standard deviation) on this new column of differences.  
  iii) Compute a 95\% confidence interval for the mean difference in TBBMC between "during lactation" and "postweaning period".    
  iv) Based on the computed confidence interval, does the data suggest mean TBBMC is different between "during lactation" and "postweaning period".    
  v) Compute the (incorrect)  two-sample t-interval on the data. See Week 10 lesson on how to do this. Does the (incorrect) two-sample t-interval lead to the same conclusion that you obtained in part (iv)? Explain.



### Code chunk
```{r} 
# start your code


# last R code line
```


2. Hexavalent chromium has been identified as an inhalation carcinogen and an air toxin of concern in a number of different locales. The article ["Airborned Hexavalent Chromium in Southwestern Ontario"](https://goo.gl/xjTQM5) gave the accompanying data on both indoor and outdoor concentration (nanograms/cubic meter) for a sample of houses selected from a certain region

```{r}
airborne <- read.csv("https://www.siue.edu/~jpailde/airborne.csv", header = TRUE)
head(airborne) # display first 6 rows
tail(airborne) # display last 6 rows
```

  i) Compute the sample mean and sample standard deviation `concentration` for both `indoor` and `outdoor`.   
  ii) Construct boxplots for the `concentration` for both `indoor` and `outdoor`.    
  iii) Based on what you see in parts (i) and (ii), do you suspect the `concentration` levels for indoor and outdoor are different? Why?  
  iv) Is a paired sample analysis appropriate for this data? Why?  
  v) Calculate a confidence interval for the population mean difference between indoor and outdoor concentrations using a confidence interval of 95\%, and interpret the resulting interval.  

### Code chunk
```{r} 
# start your code


# last R code line
```
