-
Notifications
You must be signed in to change notification settings - Fork 32
/
03_myersbriggs.Rmd
55 lines (43 loc) · 2.74 KB
/
03_myersbriggs.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
name: myersbriggs
# Myers Briggs
This visualization is of prevelence of Myers Briggs type distributions within the US population. So the data allows one to look at the relationship betweeen the four Myers Briggs types. The challenge is how to display that in one visualization. My first idea was to use a mosaic plot. However, I came across advice from "The Perceptual Edge", that generally advised against the use of the mosaic plot, instead favoring a kind of nested bar plot. I tried to implement that. While I do think that the result is pretty, I think that it still requires a lot of the reader to interpret the graph. More annotation might alleviate this burden.
```{r, fig.width=8, fig.height=8, echo = F}
data0 <- readxl::read_xlsx("raw_data/MyersBriggsTypes.xlsx")
data <- data0 %>%
mutate(`Perthousand in Population` = 1000 * `Ratio in Population`) %>%
mutate(`(E)xtroversion/(I)ntroversion` = recode(`(E)xtroversion/(I)ntroversion`,
E = "Extroversion", I = "Introversion"),
`(S)ensing/I(N)tuition` = recode(`(S)ensing/I(N)tuition`, S = "Sensing", N = "Intuition"),
`(T)hinking/(F)eeling` = recode(`(T)hinking/(F)eeling`, T = "Thinking", F = "Feeling"),
`(J)udging/(P)erceiving` = recode(`(J)udging/(P)erceiving`, J = "Judging", P = "Perceiving")) %>%
uncount(weights = `Perthousand in Population`) %>%
mutate(count = 1)
background <- data_frame(mins = c(.5, 1.5), max = c(1.5, 2.5), `judging perceiving` = c(" Judging", " Perceiving"))
```
A random sample from the data set:
```{r, echo = F}
knitr::kable(sample_n(data, 5), format = "html")
```
---
```{r myers_briggs, eval=F, echo=F}
ggplot(data) +
aes(x = `(J)udging/(P)erceiving`) +
aes(fill = `(T)hinking/(F)eeling`) +
facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) +
geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) +
geom_bar(position = "dodge") +
scale_fill_manual(values = alpha(c("lightgrey", "darkgrey", "blue", "violet"), c(.3, .3, .6, .6))) +
labs(x = "") +
labs(y = "") +
labs(fill = "") +
labs(title = "Frequency of Myers-Briggs Types") +
labs(subtitle = "Expected among 1000 individuals | @evamaerey | Source: http://www.myersbriggs.org/") +
theme_bw(base_size = 10, base_family = "Times")
```
```{r, echo = F, warning=F, message=F, eval = T, fig.show='hide'}
get_what_save_what <- "myers_briggs"
eval(parse(text = paste(knitr:::knit_code$get(get_what_save_what), collapse = "")))
ggsave(paste0("figures/", get_what_save_what, ".png"), dpi = 300)
```
`r paste(knitr::knit(text = partial_knit_chunks("myers_briggs")), collapse = "\n")`
---