-
Notifications
You must be signed in to change notification settings - Fork 6
/
ArtistDiversity_Rcode.Rmd
189 lines (169 loc) · 6.93 KB
/
ArtistDiversity_Rcode.Rmd
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
---
title: "Artist Diversity R code"
author: "Bernhard Klingenberg"
output:
html_document:
df_print: paged
pdf_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
#knitr::opts_chunk$set(tidy=TRUE)
#knitr::opts_chunk$set(tidy.opts=list(width.cutoff=70))
```
## 1. Load Artist Datafile
```{r}
path <- 'https://raw.githubusercontent.com/artofstat/ArtistDiversity/master/artistdata.csv'
artists <- read.csv(path)
```
## 2. Overall Statistics
```{r}
library(dplyr)
# Overall number of artists across all museums:
artists %>% summarize(size=n())
# Number of artists in each museum:
artists %>% group_by(museum) %>% summarize(size=n())
#Overall unique number of artists, after removing duplicates:
artists.unique <- artists %>% distinct(artist, .keep_all = TRUE)
artists.unique %>% summarize(size=n())
### Overall statistics
# Gender Distribution:
table(artists.unique$gender, useNA="always")
round(prop.table(table(artists.unique$gender)),3)
#overall gender score confidence interval:
prop.test(1025, 1025+7086, correct=FALSE)
# Gender Distribution when only including artists born after 1945 and of North American origin:
gender.NorthAmerica.1945 <- artists.unique %>% filter(year>=1945, GEO3major=="North America") %>% select(gender)
table(gender.NorthAmerica.1945,useNA="always")
round(prop.table(table(gender.NorthAmerica.1945)),3)
# Ethnicity Distribution:
table(artists.unique$ethnicity, useNA="always")
round(prop.table(table(artists.unique$ethnicity)),3)
# Simultaneous Score Confidence Intervals:
nums <- unlist(table(artists.unique$ethnicity))
sapply(nums, function(x) prop.test(x, sum(nums), correct=FALSE, conf.level = 1-0.05/5)$conf.int)
# Ethnicity Distribution when only including artists born after 1945 and of North American origin:
ethnicity.NorthAmerica.1945 <- artists.unique %>% filter(year>=1945, GEO3major=="North America") %>% select(ethnicity)
table(ethnicity.NorthAmerica.1945,useNA="always")
round(prop.table(table(ethnicity.NorthAmerica.1945)),3)
# Gender & Ethnicity Distribution:
table(artists.unique$gender, artists.unique$ethnicity, useNA="always")
round(addmargins(prop.table(table(artists.unique$gender, artists.unique$ethnicity))),3)
# Geographical Region:
table(artists.unique$GEO3major, useNA="always")
round(prop.table(table(artists.unique$GEO3major)),3)
# Birth Decade
mean(artists.unique$year, na.rm=TRUE)
```
## 3. Museum Specific Analysis
## 3.1 Gender
```{r}
genderdf <- artists %>% select(museum, gender) %>% group_by(museum) %>%
summarize(men=sum(gender=="man", na.rm=TRUE),
women=sum(gender=="woman", na.rm=TRUE),
total=men+women,
prop.women=women/total,
LB=prop.test(women,total, correct=FALSE, conf.level = 1-0.05/18)$conf.int[1],
UB=prop.test(women,total, correct=FALSE, conf.level = 1-0.05/18)$conf.int[2]
)
genderdf$padj <- NA
for (i in 1:18) {
genderdf$padj[i] <- prop.test(c(genderdf$women[i], sum(genderdf$women[-i])), c(genderdf$total[i], sum(genderdf$total[-i])), correct=FALSE)$p.value * 18
}
genderdf
```
## 3.2 Ethnicity
```{r}
ethndf <- artists %>% select(museum, ethnicity) %>% group_by(museum) %>%
summarize(asian=sum(ethnicity=="asian", na.rm=TRUE),
black=sum(ethnicity=="black", na.rm=TRUE),
hispanic=sum(ethnicity=="hispanic", na.rm=TRUE),
other=sum(ethnicity=="other", na.rm=TRUE),
white=sum(ethnicity=="white", na.rm=TRUE),
total=asian+black+hispanic+other+white
)
ethndf
```
### 3.2.1 Asian
```{r}
ethndf.asian <- ethndf %>% select(museum, asian, total) %>% group_by(museum) %>%
mutate(prop=asian/total,
LB=prop.test(asian, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[1],
UB=prop.test(asian, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[2]
)
ethndf.asian$padj <- NA
for (i in 1:18) {
ethndf.asian$padj[i] <- prop.test(c(ethndf.asian$asian[i], sum(ethndf.asian$asian[-i])), c(ethndf.asian$total[i], sum(ethndf.asian$total[-i])), correct=FALSE)$p.value * (18*5)
}
ethndf.asian
```
### 3.2.2 Black
```{r}
ethndf.black <- ethndf %>% select(museum, black, total) %>% group_by(museum) %>%
mutate(prop=black/total,
LB=prop.test(black, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[1],
UB=prop.test(black, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[2]
)
ethndf.black$padj <- NA
for (i in 1:18) {
ethndf.black$padj[i] <- prop.test(c(ethndf.black$black[i], sum(ethndf.black$black[-i])), c(ethndf.black$total[i], sum(ethndf.black$total[-i])), correct=FALSE)$p.value * (18*5)
}
ethndf.black
```
### 3.2.3 Hispanic
```{r}
ethndf.hispanic <- ethndf %>% select(museum, hispanic, total) %>% group_by(museum) %>%
mutate(prop=hispanic/total,
LB=prop.test(hispanic, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[1],
UB=prop.test(hispanic, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[2]
)
ethndf.hispanic$padj <- NA
for (i in 1:18) {
ethndf.hispanic$padj[i] <- prop.test(c(ethndf.hispanic$hispanic[i], sum(ethndf.hispanic$hispanic[-i])), c(ethndf.hispanic$total[i], sum(ethndf.hispanic$total[-i])), correct=FALSE)$p.value * (18*5)
}
ethndf.hispanic
```
### 3.2.4 White
```{r}
ethndf.white <- ethndf %>% select(museum, white, total) %>% group_by(museum) %>%
mutate(prop=white/total,
LB=prop.test(white, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[1],
UB=prop.test(white, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[2]
)
ethndf.white$padj <- NA
for (i in 1:18) {
ethndf.white$padj[i] <- prop.test(c(ethndf.white$white[i], sum(ethndf.white$white[-i])), c(ethndf.white$total[i], sum(ethndf.white$total[-i])), correct=FALSE)$p.value * (18*5)
}
ethndf.white
```
### 3.2.5 Other
```{r}
ethndf.other <- ethndf %>% select(museum, other, total) %>% group_by(museum) %>%
mutate(prop=other/total,
LB=prop.test(other, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[1],
UB=prop.test(other, total, correct=FALSE, conf.level = 1-0.05/(18*5))$conf.int[2]
)
ethndf.other$padj <- NA
for (i in 1:18) {
ethndf.other$padj[i] <- prop.test(c(ethndf.other$other[i], sum(ethndf.other$other[-i])), c(ethndf.other$total[i], sum(ethndf.other$total[-i])), correct=FALSE)$p.value * (18*5)
}
ethndf.other
```
## 3.3 Geographic Origin
```{r}
geodf <- artists %>% select(museum, GEO3major) %>% group_by(museum) %>%
summarize(Africa=round(100*prop.table(table(GEO3major))[1],1),
Asia=round(100*prop.table(table(GEO3major))[2],1),
Europe=round(100*prop.table(table(GEO3major))[3],1),
LatAm=round(100*prop.table(table(GEO3major))[4],1),
NorthAm=round(100*prop.table(table(GEO3major))[5],1),
WAsia=round(100*prop.table(table(GEO3major))[6],1)
)
geodf
```
## 3.4 Birth Year
```{r}
yeardf <- artists %>% select(museum, year) %>% group_by(museum) %>%
summarize(Avg.Year=round(mean(year, na.rm=TRUE)))
yeardf
```