What are the differences in the relationship between lifeExp ~ year among continents in the gapminder dataset?
To answer this question:
Fit lm models of lifeExp ~ year for each country as described in the ch. 25 text.
Use the broom package to make a tidy object of the coefficients (i.e.,the variable named estimate) and their confidence intervals (i.e., the variables named conf.low and conf.high).
Using your own code and style, plot these coefficients along with their confidence intervals for each country grouped by continent using ggplot and one of the facet_* functions such as facet_wrap.
Hint: remember my lecture and see this blog post http://varianceexplained.org/r/broom-intro/
BONUS +2: Plot the mean coefficient values for each continent. Plot the confidence intervals around these continent means.
gapminder %>% ggplot(aes(year, lifeExp, group = country))+geom_line(alpha = 1 / 3) +facet_wrap(~continent)
lm(data = gapminder, formula = l
lot_l <-lm(data = gapminder, formula = lifeExp ~year+country+continent)
lot_c<-tidy(lot_l,conf.int = TRUE)
lot_c %>% ggplot(aes(estimate, conf.low,conf.high)) +geom_line(aes(group = term), alpha = 1 / 3) + geom_smooth(se = FALSE)+facet_grid(~term)
Recently Asked Questions
- Related rates A ladder 10 feet long rests against a vertical wall. If the bottom of the ladder is sliding away from the wall at a rate of 1 ft/sec, how fast
- Please refer to the attachment to answer this question. This question was created from MCDB1A_Genetics_Quiz_6.
- In a candy factory, the nutty chocolate bars contain 21.6% by mass of pecans. If 7.6 kg of pecans were used for candy last Thursday, how many pounds of nutty