--- title: "Inspecting Data and Objects in R" author: "Your Name Here!" date: "February 28, 2018" output: pdf_document: default html_document: default --- ## Importing Data ```{r calculator} library(mosaicData) births <- Births ``` ## Structure of Data __Write commands to:__ 1. Display the first 6 rows and the last 6 rows 2. Output the dimension of the dataset, with and without NA's 3. Display the unique years in the dataset ```{r structure} ## Your commands here! ``` ## Changing Data Type __Write commands to:__ 1. Determine the class that weekday is in the `births` dataset 2. Determine the order of the levels of weekday in the `births` dataset 3. Reorder the levels of weekday to be Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday. ```{r dataType} ## Your commands here! ``` ## Statistical Models __You should be familar with fitting a variety of statistical tests by now (t-test, Welch's t-test, one-way ANOVA, etc.). Fit the following models:__ 1. A parametric one-way ANOVA using the `aov` function of the relationship between births and weekdays 2. A linear model of the relationship between births and weekdays 3. A parametric one-way ANOVA using the `anova` function of your linear model 4. A Tukey's HSD comparison of all possible combinations of differences in mean births by weekday (using the `TukeyHSD` function) ```{r statModels} ## Your statistical models here! ``` ## Inspecting Model Objects __With the `aov` model object:__ 1. Output the summary 2. Determine what objects are nested within the `aov` model object 3. Extract the residual degrees of freedom from the `aov` model object 4. Determine what objects are nested within the `summary` of the `aov` model object 5. How does the `aov` object differ from the `summary` of the `aov` object? ```{r aov} ## Your commands here! ``` __With the `lm` model object:__ 1. Output the summary 2. Determine what objects are nested within the `lm` model object 3. Extract the residual degrees of freedom from the `lm` model object 4. Determine what objects are nested within the `summary` of the `lm` model object 5. Extract the F-statistic from the `summary` of the `lm` model object 6. Inspect the F-statistic, what do each of the 3 entries represent? ```{r lm} ## Your commands here! ``` __With the `anova` model object:__ 1. Output the object (notice we don't need to summarize here!) 2. Determine what objects are nested within the `anova` model object 3. Extract the F-statistic and degrees of freedom from the `anova` model object ```{r anova} ## Your commands here! ``` __With the `TukeyHSD` model object:__ 1. Output the object (notice we don't need to summarize here!) 2. Determine what objects are nested within the `TukeyHSD` model object 3. Extract the `wday` object from the `TukeyHSD` model object and print it. What is different? 3. Using the extracted wday object, extract the confidence interval comparing Saturday and Sunday 4. The outputs from the `TukeyHSD` and `TukeyHSD$wday` objects look extremely similar. Why can we not extract this same confidence interval from the `TukeyHSD` model object? ```{r TukeyHSD} ## Your commands here! ```