The Mad Hatter’s Guide to Data Viz and Stats in R
  1. Data Viz and Stats
  2. Case Studies
  3. Children’s Games
  • Data Viz and Stats
    • Tools
      • Introduction to R and RStudio
    • Studio Flow and Data Kits
      • 12-Day Studio Index
      • Healthcare Data Kits
    • Visualization
      • Data
      • Inspect Data
      • Graphs
      • Summaries
      • Counts
      • Quantities
      • Groups
      • Distributions
      • Groups and Distributions
      • Change
      • Proportions
      • Hierarchy
      • Evolution and Flow
      • Ratings and Rankings
      • Surveys
      • Time
      • Space
        • Introduction to Maps
        • What is Vector Data?
        • The Grammar of Maps
        • Interactive Maps with leaflet
      • Networks
      • Miscellaneous Graphing Tools, and References
    • Inference
      • Basics
      • 🎲 Samples
      • Randomization
      • One Mean
      • Two Independent Means
      • Two Paired Means
      • Multiple Means (ANOVA)
      • Correlation
      • One Proportion
      • Two Proportions
    • Modelling
      • Linear Regression
      • Logistic Regression
      • 🕔 Time Series
    • Workflow
      • Facing the Abyss
      • I Publish, therefore I Am
      • Data Carpentry
    • Arts
      • Colours
      • Fonts for Charts
      • Font Effects in Charts
      • Branding and Typography
      • Annotations
      • More Annotations
      • Highlighting
      • Scales
    • AI Tools
      • Using gander and ellmer
      • Using Github Copilot and other AI tools to generate R code
      • Using LLMs to Explain Stat models
    • Case Studies
      • Demo:Product Packaging and Elderly People
      • Ikea Furniture
      • Movie Profits
      • Gender at the Work Place
      • Heptathlon
      • School Scores
      • Children's Games
      • Valentine’s Day Spending
      • Women Live Longer?
      • Hearing Loss in Children
      • California Transit Payments
      • Seaweed Nutrients
      • Coffee Flavours
      • Legionnaire’s Disease in the USA
      • Antarctic Sea ice
      • William Farr's Observations on Cholera in London
    • Projects
      • No Free Hunch

On this page

  • 1 Setting up R Packages
    • 1.1 Plot Fonts and Theme
  • 2 Introduction
  • 3 Read the Data
  • 4 Data Dictionary
  • 5 Analyse/Transform the Data
  • 6 Research Question
  • 7 Plot the Data
  • 8 Task and Discussion
  1. Data Viz and Stats
  2. Case Studies
  3. Children’s Games

Children’s Games

1 Setting up R Packages

library(tidyverse)
library(mosaic)
library(skimr)
library(ggformula)
library(ggbump)

1.1 Plot Fonts and Theme

Use _setup.qmd to set these up.

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:

Download PDF File

Unable to display PDF file. Download instead.

library(openintro)
data("children_gender_stereo")
glimpse(children_gender_stereo)
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

NoteQuantitative Variables

Write in.

NoteQualitative Variables

Write in.

NoteObservations

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

Note

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.
Back to top
School Scores
Valentine’s Day Spending

License: CC BY-SA 2.0

Website made with ❤️ and Quarto, by Arvind V.

Hosted by Netlify .