-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountry_c.Rmd
More file actions
70 lines (53 loc) · 2.17 KB
/
Country_c.Rmd
File metadata and controls
70 lines (53 loc) · 2.17 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
---
title: "Country and date figure"
author: "Ryan Kopper and Morgan Ruelle"
date: "7/20/2020"
output:
word_document: default
html_document: default
editor_options:
chunk_output_type: console
---
```{r}
library(networkD3)
library(tidyverse)
library(readxl)
library(readr)
#4 plot
library(scales)
library(RColorBrewer)
library(paletteer)
```
```{r setup, include=FALSE}
df <- read_excel("/Users/ryankopper/Clark University/Morgan Ruelle - Ryan Kopper Research/Push Pull Systematic Review/Table of journals included.xlsx", sheet = "included")
#df <- read_excel("C:/Users/Morgan/OneDrive - Clark University/Ryan Kopper Research/Push Pull Systematic Review/Table of journals included.xlsx", sheet = "included")
```
```{r}
df <- df %>%
mutate(Location = strsplit(Location, ",")) %>%
unnest(Location) %>% mutate(Type_research = strsplit(Type_research, ",")) %>% unnest(Type_research) %>% mutate(date_cat=cut(Date, breaks = c(-Inf, 2004, 2009, 2014, Inf), labels = c("2000 to 2004","2005 to 2009","2010 to 2014","2015 to 2019"))) %>% group_by(date_cat, `Type_research`, Location) %>% summarise(count = n())
```
Stack by experiment and survey. use Facet grid or dodge (countries)
```{r, dpi= 300, fig.width = 6.2}
png("Country_Chart.png", width = 6.2, height = 4, units = "in", res = 300, pointsize = 7)
ggplot(df, aes(x = Location, y = count, fill = Type_research))+
geom_bar(stat = "identity")+
theme_test()+
facet_grid(cols=vars(date_cat),labeller = label_wrap_gen(width = 10,
multi_line = TRUE),
space = "free_x", scales = "free_x")+
theme(strip.background =element_rect(fill="white"), axis.text.x = element_text(size = 10,angle=90,vjust=0.5,hjust=1),
legend.position = "bottom")+
ylab("Number of studies")+
scale_fill_manual(name = "Type of study",
labels = c("Field experiment", "Farmer survey"),
values = c("orangered", "blue3"))
dev.off()
```
testing out colors
"#999999", "#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00", "#CC79A7"
color schemes at
https://www.datanovia.com/en/blog/ggplot-colors-best-tricks-you-will-love/
```{r}
```