library(tidyverse)
library(datasauRus)6.2.p - Class Activity
This assignment illustrates the important of data visuals when trying to understand the distribution of data. We will use data available in the datasauRus. Please be sure you have installed this package (perhaps using the install.packages() function) before you try to proceed with the activity.
1 Problem
Discuss with a partner: What is the difference in the two datasets printed below? Which of the two datasets would be considered “tidy”?
datasaurus_dozen_wide# A tibble: 142 × 26
away_x away_y bullseye_x bullseye_y circle_x circle_y dino_x dino_y dots_x
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 32.3 61.4 51.2 83.3 56.0 79.3 55.4 97.2 51.1
2 53.4 26.2 59.0 85.5 50.0 79.0 51.5 96.0 50.5
3 63.9 30.8 51.9 85.8 51.3 82.4 46.2 94.5 50.2
4 70.3 82.5 48.2 85.0 51.2 79.2 42.8 91.4 50.1
5 34.1 45.7 41.7 84.0 44.4 78.2 40.8 88.3 50.6
6 67.7 37.1 37.9 82.6 45.0 77.9 38.7 84.9 50.3
7 53.3 97.5 39.5 80.8 48.6 78.8 35.6 79.9 25.6
8 63.5 25.1 39.6 82.7 42.1 76.9 33.1 77.6 25.5
9 68.0 81.0 34.8 80.0 41.0 76.4 29.0 74.5 25.4
10 67.4 29.7 27.6 72.8 34.6 72.7 26.2 71.4 25.6
# ℹ 132 more rows
# ℹ 17 more variables: dots_y <dbl>, h_lines_x <dbl>, h_lines_y <dbl>,
# high_lines_x <dbl>, high_lines_y <dbl>, slant_down_x <dbl>,
# slant_down_y <dbl>, slant_up_x <dbl>, slant_up_y <dbl>, star_x <dbl>,
# star_y <dbl>, v_lines_x <dbl>, v_lines_y <dbl>, wide_lines_x <dbl>,
# wide_lines_y <dbl>, x_shape_x <dbl>, x_shape_y <dbl>
datasaurus_dozen# A tibble: 1,846 × 3
dataset x y
<chr> <dbl> <dbl>
1 dino 55.4 97.2
2 dino 51.5 96.0
3 dino 46.2 94.5
4 dino 42.8 91.4
5 dino 40.8 88.3
6 dino 38.7 84.9
7 dino 35.6 79.9
8 dino 33.1 77.6
9 dino 29.0 74.5
10 dino 26.2 71.4
# ℹ 1,836 more rows
Replace this text with your answer (optional if you have a discussion with a partner, required if you do this assignment on your own).
2 Problem
Use a tidyverse chain (code separated by pipes) to determine the mean and standard deviation for the “x” and “y” variable for each unique dataset in the datasaurus_dozen tibble (i.e. tidyverse data.frame). This means that your dataset should have four variables:
mean_xmean_ysd_xsd_y
## datasaurus_summary <- datasaurus_dozen |>
## group_by(#...#) |>
## summarize(#...#)
## datasaurus_summary3 Problem
Discuss with a partner: What do you observe about the grouped means and standard deviations for both variables?
Replace this text with your answer (optional if you have a discussion with a partner, required if you do this assignment on your own).
4 Problem
Create a scatterplot (pairs of x-y points) for all 12 groups in the datasaurus_dozen dataset.
# Uncomment this plot after you have answered the previous questions.
## ggplot(datasaurus_dozen, aes(x = x, y = y)) +
## geom_point() +
## facet_wrap(~ dataset) +
## theme_bw()Note that each of the above plots follow the principle of “small multiples” which means that each plot is identical in format and differs only in the data that is represented. This is a really powerful way to compare information across groups.
5 Problem
Discuss with a partner: Describe what you see in the above plot. What do these visuals say about the representative-ness of the mean and standard deviation in describing the distribution of the data?
Replace this text with your answer (optional if you have a discussion with a partner, required if you do this assignment on your own).