-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreaddata.R
160 lines (123 loc) · 4.46 KB
/
readdata.R
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
library(gsheet)
library(tidyverse)
library(crosstalk)
library(DT)
library(ggthemes)
library(janitor)
library(cowplot)
library(plotly)
library(flexdashboard)
library(tidyverse)
library(crosstalk)
library(plotly)
library(viridis)
library(leaflet.providers)
library(leaflet)
Sys.setlocale("LC_ALL", "pt_BR.UTF-8")
#Ascari et al 202?
ascari = gsheet2tbl("https://docs.google.com/spreadsheets/d/1R6UXFcsbVgpPYyvfkPvZ81rqkyk4U_9aS7qV8TKPsxQ/edit#gid=532754791")
ascari_all <- ascari %>%
filter(labcode != 0) %>%
mutate(id = case_when(
is.na(py_binomial) ~ "No",
TRUE ~ "Yes"
)) %>%
mutate(wheat = case_when(
host_binomial == "Triticum aestivum" ~ "Wheat",
TRUE ~ "Non-wheat")) %>%
filter(host_binomial != "Oryza sativa")
ascari_all = ascari_all %>%
dplyr::select(labcode, year, lat, lon, country, state_province, county_municipality, source, host_binomial, py_binomial, py_lineage, wheat)
#BioTrigo
biotrigo = gsheet2tbl("https://docs.google.com/spreadsheets/d/1R6UXFcsbVgpPYyvfkPvZ81rqkyk4U_9aS7qV8TKPsxQ/edit#gid=1498154130")
biotrigo_all = biotrigo %>%
filter(labcode != 0) %>%
mutate(id = case_when(
is.na(py_binomial) ~ "No",
TRUE ~ "Yes"
)) %>%
mutate(wheat = case_when(
host_binomial == "Triticum aestivum" ~ "Wheat",
TRUE ~ "Non-wheat"
))%>%
filter(host_binomial != "Oryza sativa")
biotrigo_all <- biotrigo_all %>%
dplyr::select(labcode, year, lat, lon, country, state_province, county_municipality, source, host_binomial, py_binomial, py_lineage, wheat)
#Tembo et al 2021
tembo = gsheet2tbl("https://docs.google.com/spreadsheets/d/1R6UXFcsbVgpPYyvfkPvZ81rqkyk4U_9aS7qV8TKPsxQ/edit#gid=1727645447")
tembo_all = tembo %>%
filter(labcode != 0) %>%
mutate(id = case_when(
is.na(py_binomial) ~ "No",
TRUE ~ "Yes"
)) %>%
mutate(wheat = case_when(
host_binomial == "Triticum aestivum" ~ "Wheat",
TRUE ~ "Non-wheat"
))%>%
filter(host_binomial != "Oryza sativa")
tembo_all <- tembo_all %>%
dplyr::select(labcode, year, lat, lon, country, state_province, county_municipality, source, host_binomial, py_binomial, py_lineage, wheat)
# #Croll 2021
# croll = gsheet2tbl("https://docs.google.com/spreadsheets/d/1R6UXFcsbVgpPYyvfkPvZ81rqkyk4U_9aS7qV8TKPsxQ/edit#gid=106318963")
# croll_all = croll %>%
# filter(labcode != 0) %>%
# mutate(id = case_when(
# is.na(py_binomial) ~ "No",
# TRUE ~ "Yes"
# )) %>%
# mutate(wheat = case_when(
# host_binomial == "Triticum aestivum" ~ "Wheat",
# TRUE ~ "Non-wheat"
# ))
#
# croll_all <- croll_all %>%
# dplyr::select(labcode, year, lat, lon, country, state_province, county_municipality, source, host_binomial, py_binomial, py_lineage, wheat)
#
# #Rahnama et al 202?
# Rahnama = gsheet2tbl("https://docs.google.com/spreadsheets/d/1R6UXFcsbVgpPYyvfkPvZ81rqkyk4U_9aS7qV8TKPsxQ/edit#gid=2126271613")
# Rahnama_all = Rahnama %>%
# filter(labcode != 0) %>%
# mutate(id = case_when(
# is.na(py_binomial) ~ "No",
# TRUE ~ "Yes"
# )) %>%
# mutate(wheat = case_when(
# host_binomial == "Triticum aestivum" ~ "Wheat",
# TRUE ~ "Non-wheat"
# ))
#
# Rahnama_all <- Rahnama_all %>%
# dplyr::select(labcode, year, lat, lon, country, state_province, county_municipality, source, host_binomial, py_binomial, py_lineage, wheat)
# #Castroaugudin et al 2016
# Castroaugudin = gsheet2tbl("https://docs.google.com/spreadsheets/d/1R6UXFcsbVgpPYyvfkPvZ81rqkyk4U_9aS7qV8TKPsxQ/edit#gid=1870344414")
# Castroaugudin_all = Castroaugudin %>%
# filter(labcode != 0) %>%
# mutate(id = case_when(
# is.na(py_binomial) ~ "No",
# TRUE ~ "Yes"
# )) %>%
# mutate(wheat = case_when(
# host_binomial == "Triticum aestivum" ~ "Wheat",
# TRUE ~ "Non-wheat"
# ))
#
# Castroaugudin_all <- Castroaugudin_all %>%
# dplyr::select(labcode, year, lat, lon, country, state_province, county_municipality, source, host_binomial, py_binomial, py_lineage, wheat)
#Raw data
set.seed(1)
wb_all = bind_rows(ascari_all, biotrigo_all, tembo_all) %>%
unite("latlong", lat, lon, sep ="/", remove = F ) %>%
group_by(latlong) %>%
mutate(n = n(),
lat = case_when(n > 1 ~ rnorm(n, lat,0.01),
n == 1 ~ lat),
lon = case_when(n > 1 ~ rnorm(n, lon,0.01),
n == 1 ~ lon)
) %>%
ungroup() %>%
dplyr::select(-latlong)
sd <- SharedData$new(wb_all)
wb_all2 <- wb_all %>%
select(labcode, year, country, source, host_binomial, py_binomial, py_lineage, wheat)
sd2 <- SharedData$new(wb_all2)