Assignment 2

Preparation

Download this Rmarkdown file, fill in your name and student number, and complete your assignment in the Rmarkdown file. “knit” your text and code into an pdf-file, and upload this pdf-file on Brightspace before the next lecture.

Packages

library(ggplot2)

Dataset

The European Social Survey is a cross-national survey that measures the attitudes, beliefs and behaviour on diverse topics from several European nations. patterns of diverse populations in more than thirty nations. These data are freely available. For this assignment, we’ll only use the data from 2018 from ten countries on a selected set of variables with hundred cases for each country.

data <- read.csv2("http://stulp.gmw.rug.nl/dataviz/ESS.csv", header = TRUE)
head(data)
##     cntry ageadlt agemage ageoage iaglptn iagmr iagpnt iagrtr tygledu tyglvp
## 1 Austria      20      30      90      20    25     25     65      13     17
## 2 Austria      18      27      55      20    22     25     65      19     17
## 3 Austria      20      45      75      19    25     25     60      14     16
## 4 Austria      20      30      70      22    27     25     57      15     18
## 5 Austria      24      50      70      20    30     33     65      14     17
## 6 Austria      21      37      60      20    27     28     60      17     18
##   tygmr tygpnt tygrtr tolvpnt tochld towkht
## 1    18     18     45      25     45     66
## 2    17     17     60      25     30     60
## 3    18     20     50      25     45     65
## 4    20     23     50      25     40     62
## 5    18     18     55      27     55     65
## 6    21     25     50      25     50     65

There is one country variable (cntry), and the rest of the variables concern question on the “appropriate” or “right” age for several topics. This is the list of the variables and their explanation:

## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
Variable Explanation
ageadlt Age become adults
agemage Age reach middle age
ageoage Age reach old age
iaglptn Start living with partner not married to, ideal age
iagmr Get married, ideal age
iagpnt Become mother/ father, ideal age
iagrtr Retire permanently, ideal age
tygledu Leave full-time education, age too young
tyglvp Start living with partner not married to, age too young
tygmr Get married, age too young
tygpnt Become mother/ father, age too young
tygrtr Retire permanently, age too young
tolvpnt Still be living with parents, age too old
tochld Consider having more children, age too old
towkht Be working 20 hours or more per week, age too old

Your task

On the basis of these data from the ESS-survey, try to create an informative and pretty graph. Include the following elements.

  • Create a plot that compares distributions across different countries. You can choose what variable to focus on and what geom(s) work best.

  • Explain in no more than 250 words what the graph is showing, and what unique insights it delivers. Also reflect on what it fails to show or what you would have liked to include in the graph but was not able to.

  • Create appropriate axis-labels and titles.

  • Create your own theme and add this theme to your graph.

  • Be sure to create clean code (see here)

Submit your PDF-file online

When you are done with your assignment, try clicking the “Knit”-button in Rstudio so that your code will be knitted into a pdf-file. Submit this file on Brightspace.

If you see an error appear, try to fix the error and try again. If you can’t get the “knitting” to work, then you can copy your code, text, and graphs into a word-file and submit it on Brightspace.