forked from CrumpLab/LabJournalWebsite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataVis.Rmd
More file actions
92 lines (73 loc) · 2.95 KB
/
DataVis.Rmd
File metadata and controls
92 lines (73 loc) · 2.95 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
90
91
---
title: "DataVis"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
#Figure 6
```{r}
library(ggplot2)
non_social <- c(0,1,3,5,25,46,52,58)
social <- c(12,47,5,41,48,32,56,59)
plot_df <- data.frame(non_social,social)
ggplot(plot_df, aes(x=non_social,y=social)) +
geom_point(size=2) +
geom_smooth(method="lm", se = FALSE) +
theme_classic() +
xlab("Avg Frequency of Non Social Risk") +
ylab("Avg Frequency of Social Risk") +
coord_cartesian(xlim=c(0,70),ylim=c(0,70))
```
#Figure 1a
```{r}
library(ggplot2)
group <- c(rep("Doctor Study", 10), rep("Butcher Study", 10), rep("Firefighter Study", 10),
rep("Construction Worker Study", 10))
group_order <- factor(group, levels = c("Doctor Study", "Butcher Study", "Firefighter Study", "Construction Worker Study"))
gender <- c(rep("Man More Likely",2), rep("Equally Likely",8),
rep("Man More Likely",3), rep("Equally Likely",5), rep("Woman More Likely",2),
rep("Man More Likely",4), rep("Equally Likely",5), rep("Woman More Likely",1),
rep("Man More Likely",3), rep("Equally Likely",5), rep("Woman More Likely",2))
gender_order <- factor(gender, levels = c("Woman More Likely", "Equally Likely", "Man More Likely"))
plot_df2 <- data.frame(group_order,gender_order)
ggplot(plot_df2, aes(group_order, fill = gender_order)) +
geom_bar(position = "fill") +
theme_classic() +
xlab("") +
ylab("Precentage of Participants") +
scale_fill_discrete(name = "") +
theme(legend.position = "top")
```
# Figure 1b
```{r}
library(ggplot2)
group <- c(doc_study = rep("Doctor Study", 6), buh_study = rep("Butcher Study", 6),
fire_study = rep("Firefighter Study", 6),
cons_study = rep("Construction Worker Study", 6))
group_order <- factor(group, levels = c("Doctor Study", "Butcher Study", "Firefighter Study", "Construction Worker Study"))
eval_data <- c(1,1,1,2,3,4,5,6,1,1,2,2,2,2,3,4,1,2,3,4,4,5,6,7)
plot_df3 <- data.frame(group_order,eval_data)
ggplot(plot_df3, aes(group_order, eval_data)) +
geom_violin(fill="gray80") +
theme_classic() +
ylab("Evaluation of Person X") +
xlab("")
```
# Figure 6
```{r}
library(ggplot2)
Names <-rep(c("Dara", "Azalea", "Barbi", "Rowena", "Fiona"), each = 2)
MF <- rnorm(10,45,25)
Condition <- rep(c("Social","NonSocial"),5)
Condition_ordered <- factor(Condition, c("Social", "NonSocial"))
Aversity <- rep(c("Aversive","Not Aversive"), times=c(4,6))
plot_df4 <- data.frame(Names, MF, Condition_ordered, Aversity)
ggplot(plot_df4, aes(x = Condition_ordered, y = MF, group = Names)) +
geom_line(aes(linetype=Aversity))+
geom_text(label=Names) +
theme_classic() +
ylab("Mean Frequency of Risky Choice") +
xlab("") +
theme(legend.position="none")
```