-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
90 lines (70 loc) · 2.37 KB
/
Copy pathREADME.Rmd
File metadata and controls
90 lines (70 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
fig.retina = 2
)
library(tidyverse)
library(patchwork)
```
# Dataforsocialscience
The goal of `dataforsocialscience` is to bundle a set of data sets that are useful for teaching statistics in a social science field.
## Installation
You can install the current version of dataforsocialscience from github as follows:
```r
if(!require(remotes)){
install.packages(remotes)
}
remotes::install_github("statisticsforsocialscience/dataforsocialscience")
```
## Example data sets
These are the datasets contained in this package.
### Robot care
```{r example}
library(tidyverse)
library(dataforsocialscience)
robo_care %>% names()
robo_care %>%
ggplot() +
aes(cse, y = robo_bed, color = gender) +
geom_jitter(width = 0.2, height = 0.2, alpha = 0.8) +
geom_smooth(method = "lm") +
scale_x_continuous("Computer Self-Efficacy", breaks = 1:6) +
scale_y_continuous("Would you accept that a robot brings you to bed?", breaks = 1:6) +
labs(color = "Gender")
```
### Phone usage
```{r example_phone}
data("anova_phone")
ggplot(anova_phone) +
aes(phone, whatsapp, color = phone) +
geom_point() +
ggtitle("Sum of Squares within") +
scale_y_continuous("Whatsapp messages per day", breaks = 1:10) +
geom_line(data = data.frame(x = c(0.6,1.4), y = c(2.0,2.0)), aes(x,y), inherit.aes = FALSE, size = 1, color = 2) +
geom_label(label = "M1", x = 1.3, y = 2.3, inherit.aes = FALSE, size = 6) +
geom_line(data = data.frame(x = c(1.6,2.4), y = c(5.0,5.0)), aes(x, y), inherit.aes = FALSE, size = 1, color = 3) +
geom_label(label = "M2", x = 2.3, y = 5.3, inherit.aes = FALSE, size = 6) +
geom_line(data = data.frame(x = c(2.6,3.4), y = c(8.0,8.0)), aes(x,y), inherit.aes = FALSE, size = 1, color = 4) +
geom_label(label = "M3", x = 3.3, y = 8.3, inherit.aes = FALSE, size = 6)
```
### Simpson Paradox
```{r simpson}
p1 <- simpson_paradox %>%
ggplot() +
aes(x = V2, y = V1, color = group) +
geom_point() +
geom_smooth(method = "lm")
p2 <- simpson_paradox %>%
ggplot() +
aes(x = V2, y = V1) +
geom_point() +
geom_smooth(method = "lm")
p2 + p1 + patchwork::plot_annotation(title = "Demonstrating the Simpson Paradox")
```