Children’s Games
1 Setting up R Packages
Plot Fonts and Theme
Show the Code
library(systemfonts)
library(showtext)
## Clean the slate
systemfonts::clear_local_fonts()
systemfonts::clear_registry()
##
showtext_opts(dpi = 96) # set DPI for showtext
sysfonts::font_add(
family = "Alegreya",
regular = "../../../../../../fonts/Alegreya-Regular.ttf",
bold = "../../../../../../fonts/Alegreya-Bold.ttf",
italic = "../../../../../../fonts/Alegreya-Italic.ttf",
bolditalic = "../../../../../../fonts/Alegreya-BoldItalic.ttf"
)
sysfonts::font_add(
family = "Roboto Condensed",
regular = "../../../../../../fonts/RobotoCondensed-Regular.ttf",
bold = "../../../../../../fonts/RobotoCondensed-Bold.ttf",
italic = "../../../../../../fonts/RobotoCondensed-Italic.ttf",
bolditalic = "../../../../../../fonts/RobotoCondensed-BoldItalic.ttf"
)
showtext_auto(enable = TRUE) # enable showtext
##
theme_custom <- function() {
font <- "Alegreya" # assign font family up front
"%+replace%" <- ggplot2::"%+replace%" # nolint
theme_classic(base_size = 14, base_family = font) %+replace% # replace elements we want to change
theme(
text = element_text(family = font), # set base font family
# text elements
plot.title = element_text( # title
family = font, # set font family
size = 24, # set font size
face = "bold", # bold typeface
hjust = 0, # left align
margin = margin(t = 5, r = 0, b = 5, l = 0)
), # margin
plot.title.position = "plot",
plot.subtitle = element_text( # subtitle
family = font, # font family
size = 14, # font size
hjust = 0, # left align
margin = margin(t = 5, r = 0, b = 10, l = 0)
), # margin
plot.caption = element_text( # caption
family = font, # font family
size = 9, # font size
hjust = 1
), # right align
plot.caption.position = "plot", # right align
axis.title = element_text( # axis titles
family = "Roboto Condensed", # font family
size = 12
), # font size
axis.text = element_text( # axis text
family = "Roboto Condensed", # font family
size = 9
), # font size
axis.text.x = element_text( # margin for axis text
margin = margin(5, b = 10)
)
# since the legend often requires manual tweaking
# based on plot content, don't define it here
)
}
## Use available fonts in ggplot text geoms too!
ggplot2::update_geom_defaults(geom = "text", new = list(
family = "Roboto Condensed",
face = "plain",
size = 3.5,
color = "#2b2b2b"
))
ggplot2::update_geom_defaults(geom = "label", new = list(
family = "Roboto Condensed",
face = "plain",
size = 3.5,
color = "#2b2b2b"
))
## Set the theme
ggplot2::theme_set(new = theme_custom())
2 Introduction
Children in the ages of 6 to 7 years are asked if they want to play two games. This dataset pertains to their responses about the two games. The research is based on this paper:
Lin Bian et al. ,Gender stereotypes about intellectual ability emerge early and influence children’s interests. Science 355,389-391(2017).DOI:10.1126/science.aah6524. This very short and crisp paper is available here.
3 Read the Data
The data is part of the R package openintro
. Yes, install it. From the help menu ?children_gender_stereo
:
This data object is more unusual than most. It is a list of 4 data frames. The four data frames correspond to the data used in Studies 1-4 of the referenced paper, and these data frames each have variables (columns) that are explained below:
List of 4
$ 1:'data.frame': 192 obs. of 5 variables:
..$ subject : int [1:192] 1 2 3 4 5 6 7 8 9 10 ...
..$ gender : chr [1:192] "female" "female" "female" "male" ...
..$ age : int [1:192] 7 7 7 6 7 5 5 5 5 5 ...
..$ trait : chr [1:192] "smart" "smart" "smart" "smart" ...
..$ stereotype: num [1:192] 0.611 0.278 0.722 0.556 1 ...
$ 2:'data.frame': 576 obs. of 7 variables:
..$ subject : int [1:576] 1 2 3 4 5 6 7 8 9 10 ...
..$ gender : chr [1:576] "male" "male" "male" "female" ...
..$ age : int [1:576] 6 5 7 5 5 7 6 6 5 5 ...
..$ trait : chr [1:576] "smart" "smart" "smart" "smart" ...
..$ target : chr [1:576] "adults" "adults" "adults" "adults" ...
..$ stereotype : num [1:576] 0.75 1 0.25 1 0.25 0.75 0 0.5 0.75 1 ...
..$ high_achieve_caution: num [1:576] 0.25 1 0.25 1 0.75 0.5 0.5 0.75 0.5 0.5 ...
$ 3:'data.frame': 128 obs. of 7 variables:
..$ subject : int [1:128] 1 2 3 4 5 6 7 8 9 10 ...
..$ gender : chr [1:128] "female" "male" "female" "male" ...
..$ age : int [1:128] 7 7 7 7 7 6 7 7 6 6 ...
..$ game : chr [1:128] "smart" "smart" "smart" "smart" ...
..$ interest : num [1:128] 0.328 0.781 0.781 -0.213 -2.304 ...
..$ difference: num [1:128] 0.244 0.453 0.209 -0.577 -1.523 ...
..$ stereotype: num [1:128] -1.7982 0.0866 -1.7982 0.7784 -0.6051 ...
$ 4:'data.frame': 96 obs. of 4 variables:
..$ subject : int [1:96] 1 2 3 4 5 6 7 8 9 10 ...
..$ gender : chr [1:96] "female" "female" "female" "female" ...
..$ age : int [1:96] 6 6 6 6 6 6 6 6 6 6 ...
..$ interest: num [1:96] 0.3924 0.68 -0.7163 -0.4279 -0.0413 ...
Let us choose, arbitrarily, the third study:
## Choosing, arbitrarily, the third game/third study
children_gender_stereo[[3]] -> games3
glimpse(games3)
Rows: 128
Columns: 7
$ subject <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, …
$ gender <chr> "female", "male", "female", "male", "female", "female", "ma…
$ age <int> 7, 7, 7, 7, 7, 6, 7, 7, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6,…
$ game <chr> "smart", "smart", "smart", "smart", "smart", "smart", "smar…
$ interest <dbl> 0.328241235, 0.781351865, 0.781351865, -0.213178560, -2.303…
$ difference <dbl> 0.24441071, 0.45311063, 0.20869992, -0.57713058, -1.5226918…
$ stereotype <dbl> -1.79820307, 0.08662039, -1.79820307, 0.77835148, -0.605110…
4 Data Dictionary
Write in.
Write in.
Write in.
5 Analyse/Transform the Data
```{r}
#| label: data-preprocessing
#
# Write in your code here
# to prepare this data as shown below
# to generate the plot that follows
# Counts, histograms etc
```
6 Research Question
Is there a difference the average interest level between Boys and Girls for the two kinds of games, “Smart Game” and “Try Hard Game”? Does that lead to the inference of how children acquire gender stereotypes about play?
7 Plot the Data
8 Task and Discussion
Complete the Data Dictionary. Select and Transform the variables as shown. Create the graphs shown below and discuss the following questions:
- Identify the type of charts
- Identify the variables used for various geometrical aspects (x, y, fill…). Name the variables appropriately.
- What research activity might have been carried out to obtain the data graphed here? Provide some details.
- Does the Chart answer the Hypothesis? Justify?
- Write a 2-line story based on the chart, describing your inference/surprise.