diff --git a/model-many.Rmd b/model-many.Rmd index 949d58b..31cc2f4 100644 --- a/model-many.Rmd +++ b/model-many.Rmd @@ -120,7 +120,7 @@ models <- map(by_country$data, country_model) ``` However, rather than leaving leaving the list of models as a free-floating object, I think it's better to store it as a variable in the `by_country` data frame. This is why I think list-columns are such a good idea. In the course of working with these countries, we are going to have lots of lists where we have one element per country. So why not store them all together in one data frame? - +%>% In other words, instead of creating a new object in the global environment, we're going to create a new variable in the `by_country` data frame. That's a job for `dplyr::mutate()`: ```{r} @@ -191,7 +191,7 @@ The broom package provides three general tools for turning models in to tidy dat Here we'll use `broom::glance()` to extract some model quality metrics. If we apply it to a model, we get a data frame with a single row: ```{r} -glance(nz_mod) +broom::glance(nz_mod) ``` We can use `mutate()` and `unnest()` to create a data frame with a row for each country: diff --git a/variation.Rmd b/variation.Rmd index d31f3ea..a879747 100644 --- a/variation.Rmd +++ b/variation.Rmd @@ -164,7 +164,7 @@ Now that you can visualize variation, what should you look for in your plots? An * *Outliers* - Outliers are data points that do not seem to fit the overall pattern of variation, like the diamond on the far right of the histogram below. This diamond has a y dimension of `r diamonds$y[which(diamonds$y > 50)]` mm, which is much larger than the other diamonds. + Outliers are data points that do not seem to fit the overall pattern of variation, like the diamond on the far right of the histogram below. This diamond has a y dimension of 59mm, which is much larger than the other diamonds. ```{r echo = FALSE, message = FALSE, fig.height = 2} ggplot(diamonds[24000:24500, ]) + geom_histogram(aes(x = y), binwidth = 0.25)