-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
190 lines (190 loc) · 9.5 KB
/
.Rhistory
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
188
189
190
library(readr)
library(dplyr)
library(stringr)
sahel_rfh_20240618_rainfall_data <- read_csv("C:/Users/AHema/OneDrive - CGIAR/Desktop/2024/WFP/Spatial climate data/sahel_rfh_20240618.csv")
sahel_rfh_20240618_rainfall_data$annee = lubridate::year(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$mois = lubridate::month(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$jour = lubridate::day(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data = sahel_rfh_20240618_rainfall_data %>%
mutate(ID = paste0(location,mois,jour))
###############
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
filter(annee >=1989 & annee <= 2018)
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data_rfh_avg %>%
group_by(ID) %>%
summarise(rfh_avg_hema = ifelse(rfh==0,0,mean(rfh,na.rm = T))) %>%
#ungroup() %>%
select(ID,rfh_avg_hema)
###########
rain_fall = left_join(sahel_rfh_20240618_rainfall_data,sahel_rfh_20240618_rainfall_data_rfh_avg) %>%
select(ID,time, location,rfh,rfh_avg_hema,rfh_avg,rfq,valids)
View(rain_fall)
sahel_rfh_20240618_rainfall_data <- read_csv("C:/Users/AHema/OneDrive - CGIAR/Desktop/2024/WFP/Spatial climate data/sahel_rfh_20240618.csv")
sahel_rfh_20240618_rainfall_data$annee = lubridate::year(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$mois = lubridate::month(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$jour = lubridate::day(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data = sahel_rfh_20240618_rainfall_data %>%
mutate(ID = paste0(location,mois,jour))
###############
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
filter(annee >=1989 & annee <= 2018)
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data_rfh_avg %>%
group_by(ID) %>%
summarise(rfh_avg_hema = ifelse(rfh==0,0,mean(rfh,na.rm = T))) %>%
#ungroup() %>%
select(ID,rfh_avg_hema)
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data_rfh_avg %>%
distinct()
###########
rain_fall = left_join(sahel_rfh_20240618_rainfall_data,sahel_rfh_20240618_rainfall_data_rfh_avg) %>%
select(ID,time, location,rfh,rfh_avg_hema,rfh_avg,rfq,valids)
sahel_rfh_20240618_rainfall_data <- read_csv("C:/Users/AHema/OneDrive - CGIAR/Desktop/2024/WFP/Spatial climate data/sahel_rfh_20240618.csv")
View(sahel_rfh_20240618_rainfall_data)
sahel_rfh_20240618_rainfall_data <- sahel_rfh_20240618_rainfall_data %>%
select(-1)
View(sahel_rfh_20240618_rainfall_data)
sahel_rfh_20240618_rainfall_data$annee = lubridate::year(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$mois = lubridate::month(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$jour = lubridate::day(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data = sahel_rfh_20240618_rainfall_data %>%
mutate(ID = paste0(location,mois,jour))
###############
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
filter(annee >=1989 & annee <= 2018)
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data_rfh_avg %>%
group_by(ID) %>%
summarise(rfh_avg_hema = mean(rfh,na.rm = T)) %>%
#ungroup() %>%
select(ID,rfh_avg_hema)
###########
rain_fall = left_join(sahel_rfh_20240618_rainfall_data,sahel_rfh_20240618_rainfall_data_rfh_avg) %>%
select(ID,time, location,rfh,rfh_avg_hema,rfh_avg,rfq,valids)
sahel_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
group_by(ID) %>%
summarise(rfh_avg_hema2 = mean(rfh,na.rm = T)) %>%
#ungroup() %>%
select(ID,rfh_avg_hema2)
rain_fall = left_join(rain_fall,sahel_rfh_avg) %>%
select(time, location,rfh,rfh_avg_hema,rfh_avg_hema2,rfh_avg,rfq,valids)
rain_fall = rain_fall %>%
mutate(rfq_hema = (rfh + 5)*100/(rfh_avg_hema + 5),
rfh_avg_diff = rfh_avg_hema - rfh_avg,
rfq_diff = rfq_hema - rfq) %>%
arrange(location,time)
writexl::write_xlsx(rain_fall,"sahel_rfh_20240618_rainfall_data.xlsx")
rain_fall_notok = rain_fall %>%
filter(rfh_avg == 0 & rfh_avg_hema!=0)
writexl::write_xlsx(rain_fall_notok,"rain_fall_notok.xlsx")
library(readr)
library(dplyr)
library(stringr)
sahel_rfh_20240618_rainfall_data <- read_csv("C:/Users/AHema/OneDrive - CGIAR/Desktop/2024/WFP/Spatial climate data/sahel_rfh_20240618.csv")
sahel_rfh_20240618_rainfall_data <- sahel_rfh_20240618_rainfall_data %>%
select(-1)
sahel_rfh_20240618_rainfall_data$annee = lubridate::year(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$mois = lubridate::month(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$jour = lubridate::day(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data = sahel_rfh_20240618_rainfall_data %>%
mutate(ID = paste0(location,mois,jour))
###############
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
filter(annee >=1989 & annee <= 2018)
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data_rfh_avg %>%
group_by(ID) %>%
summarise(rfh_avg_hema = mean(rfh,na.rm = T)) %>%
#ungroup() %>%
select(ID,rfh_avg_hema)
###########
rain_fall = left_join(sahel_rfh_20240618_rainfall_data,sahel_rfh_20240618_rainfall_data_rfh_avg) %>%
select(ID,time, location,rfh,rfh_avg_hema,rfh_avg,rfq,valids)
sahel_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
group_by(ID) %>%
summarise(rfh_avg_hema2 = mean(rfh,na.rm = T)) %>%
#ungroup() %>%
select(ID,rfh_avg_hema2)
rain_fall = left_join(rain_fall,sahel_rfh_avg) %>%
select(ID,time, location,rfh,rfh_avg_hema,rfh_avg_hema2,rfh_avg,rfq,valids)
rain_fall = rain_fall %>%
mutate(rfq_hema = (rfh + 5)*100/(rfh_avg_hema + 5),
rfh_avg_diff = rfh_avg_hema - rfh_avg,
rfq_diff = rfq_hema - rfq) %>%
arrange(location,time)
writexl::write_xlsx(rain_fall,"sahel_rfh_20240618_rainfall_data.xlsx")
rain_fall_notok = rain_fall %>%
filter(rfh_avg == 0 & rfh_avg_hema!=0)
writexl::write_xlsx(rain_fall_notok,"rain_fall_notok.xlsx")
sahel_rfh_20240618_rainfall_data <- read_csv("C:/Users/AHema/OneDrive - CGIAR/Desktop/2024/WFP/Spatial climate data/sahel_rfh_20240618.csv")
sahel_rfh_20240618_rainfall_data <- sahel_rfh_20240618_rainfall_data %>%
select(-1)
sahel_rfh_20240618_rainfall_data$annee = lubridate::year(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$mois = lubridate::month(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$jour = lubridate::day(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data = sahel_rfh_20240618_rainfall_data %>%
mutate(ID = paste0(location,"_",mois,"_",jour))
###############
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
filter(annee >=1989 & annee <= 2018)
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data_rfh_avg %>%
group_by(ID) %>%
summarise(rfh_avg_hema = mean(rfh,na.rm = T)) %>%
#ungroup() %>%
select(ID,rfh_avg_hema)
###########
rain_fall = left_join(sahel_rfh_20240618_rainfall_data,sahel_rfh_20240618_rainfall_data_rfh_avg) %>%
select(ID,time, location,rfh,rfh_avg_hema,rfh_avg,rfq,valids)
sahel_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
group_by(ID) %>%
summarise(rfh_avg_hema2 = mean(rfh,na.rm = T)) %>%
#ungroup() %>%
select(ID,rfh_avg_hema2)
rain_fall = left_join(rain_fall,sahel_rfh_avg) %>%
select(ID,time, location,rfh,rfh_avg_hema,rfh_avg_hema2,rfh_avg,rfq,valids)
rain_fall = rain_fall %>%
mutate(rfq_hema = (rfh + 5)*100/(rfh_avg_hema + 5),
rfh_avg_diff = rfh_avg_hema - rfh_avg,
rfq_diff = rfq_hema - rfq) %>%
arrange(location,time)
writexl::write_xlsx(rain_fall,"sahel_rfh_20240618_rainfall_data.xlsx")
rain_fall_notok = rain_fall %>%
filter(rfh_avg == 0 & rfh_avg_hema!=0)
sahel_rfh_20240618_rainfall_data <- read_csv("C:/Users/AHema/OneDrive - CGIAR/Desktop/2024/WFP/Spatial climate data/sahel_rfh_20240618.csv")
sahel_rfh_20240618_rainfall_data <- sahel_rfh_20240618_rainfall_data %>%
select(-1)
sahel_rfh_20240618_rainfall_data$annee = lubridate::year(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$mois = lubridate::month(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data$jour = lubridate::day(sahel_rfh_20240618_rainfall_data$time)
sahel_rfh_20240618_rainfall_data = sahel_rfh_20240618_rainfall_data %>%
mutate(ID = paste0(location,"_",mois,"_",jour))
###############
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
filter(annee >=1989 & annee <= 2018)
sahel_rfh_20240618_rainfall_data_rfh_avg = sahel_rfh_20240618_rainfall_data_rfh_avg %>%
group_by(ID) %>%
summarise(rfh_avg_hema = mean(rfh,na.rm = T)) %>%
#ungroup() %>%
select(ID,rfh_avg_hema)
###########
rain_fall = left_join(sahel_rfh_20240618_rainfall_data,sahel_rfh_20240618_rainfall_data_rfh_avg) %>%
select(ID,time, location,rfh,rfh_avg_hema,rfh_avg,rfq,valids)
sahel_rfh_avg = sahel_rfh_20240618_rainfall_data %>%
group_by(ID) %>%
summarise(rfh_avg_hema2 = mean(rfh,na.rm = T)) %>%
#ungroup() %>%
select(ID,rfh_avg_hema2)
rain_fall = left_join(rain_fall,sahel_rfh_avg) %>%
select(time, location,rfh,rfh_avg_hema,rfh_avg_hema2,rfh_avg,rfq,valids)
rain_fall = rain_fall %>%
mutate(rfq_hema = (rfh + 5)*100/(rfh_avg_hema + 5),
rfq_hema2 = (rfh + 5)*100/(rfh_avg_hema2 + 5)) %>%
arrange(location,time)
writexl::write_xlsx(rain_fall,"sahel_rfh_20240618_rainfall_data.xlsx")
rain_fall_notok = rain_fall %>%
filter(rfh_avg == 0 & rfh_avg_hema!=0)
decad_janvier = sahel_rfh_20240618_rainfall_data %>%
filter(mois==1 & (jour ==11|jour ==21)) %>%
filter(location == "BF1300") %>%
select(location,rfh,rfh_avg_hema,time)
decad_janvier = rain_fall %>%
filter(mois==1 & (jour ==11|jour ==21)) %>%
filter(location == "BF1300") %>%
select(location,rfh,rfh_avg_hema,time)