Join tables with dplyr

Data and libraries

library(readr)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(ggplot2)
library(gapminder)
library(glue)
marriage_df <- read_csv(file = glue("/lnet/aic/personal/cinkova/",
"R_BEGINNERS_SHORT/datasets_ATRIUM/gapminder_firstmarriage.csv"))
Rows: 185 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): country
dbl (1): 2005

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# or copy it to your location and read from there
str(marriage_df)
spc_tbl_ [185 × 2] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ country: chr [1:185] "Afghanistan" "Albania" "Algeria" "Angola" ...
 $ 2005   : num [1:185] 17.8 23.3 29.6 NA 23.3 ...
 - attr(*, "spec")=
  .. cols(
  ..   country = col_character(),
  ..   `2005` = col_double()
  .. )
 - attr(*, "problems")=<externalptr> 

Task

  1. Read the file as above and rename the column 2005 to “marriage”. Retype this. Mind the quotes in “2005”. Try without. They are very important when you get a column with an ambiguous name. With even weirder names you may even need backticks (`2005`).

  2. Filter gapminder for year 2007.

  3. Join it with marriage_df (only matching countries).

  4. Plot linear models of the association between the age of the first marriage in women and gdpPercap, pop, and lifeExp (each in a separate plot).

  5. Plot the same three models but this time map continent on color.

Write a short interpretation of the models.

Linear model of the association between the age of the first marriage in women and lifeExp

Linear model of the association between the age of the first marriage in women and gdpPercap

Linear model of the association between the age of the first marriage in women and pop

Linear model of the association between the age of the first marriage in women and lifeExp, by continents

Linear model of the association between the age of the first marriage in women and gdpPercap, by continents

Linear model of the association between the age of the first marriage in women and pop, by continents