@@ -55,7 +55,7 @@ forecast_summary_clima <- function(input_dir,
55
55
# For each starting date and forecast date, calculate the percentage of
56
56
# pixels exceeding the high danger level
57
57
w <- raster :: stack()
58
- for (i in 1 : length (my_dates )) {
58
+ for (i in seq_along (my_dates )) {
59
59
print(my_dates [i ])
60
60
61
61
# transform dates to strings to build file name
@@ -140,12 +140,13 @@ forecast_summary_clima <- function(input_dir,
140
140
}
141
141
frp_cropped <- mask_crop_subset(r = frp , p = p , mask = TRUE , crop = FALSE )
142
142
frp_ts <- as.numeric(raster :: cellStats(frp_cropped , sum ))
143
- df_frp <- data.frame (date = forecast_dates [1 : length(frp_ts )],
143
+ frp_ts_length <- length(frp_ts )
144
+ df_frp <- data.frame (date = forecast_dates [1 : frp_ts_length ],
144
145
frp_original = frp_ts ,
145
- frp = plotrix :: rescale(frp_ts , c(0 , length( frp_ts ) )))
146
- labels_obs <- round(plotrix :: rescale(1 : length( frp_ts ) ,
146
+ frp = plotrix :: rescale(frp_ts , c(0 , frp_ts_length )))
147
+ labels_obs <- round(plotrix :: rescale(1 : frp_ts_length ,
147
148
c(1 , max(frp_ts ))),
148
- 0 )[1 : length( frp_ts ) ]
149
+ 0 )[1 : frp_ts_length ]
149
150
}
150
151
151
152
# Make the boxy forecast plot using ggplot2
@@ -158,10 +159,10 @@ forecast_summary_clima <- function(input_dir,
158
159
" \n percentile = " , threshold )) +
159
160
theme_bw() + labs(x = " Observation date" , y = " Forecast date" ) +
160
161
scale_x_continuous(expand = c(0 , 0 ),
161
- breaks = 1 : length (observation_dates ),
162
+ breaks = seq_along (observation_dates ),
162
163
labels = as.character(observation_dates )) +
163
164
scale_y_continuous(expand = c(0 , 0 ),
164
- breaks = 1 : length (forecast_dates ),
165
+ breaks = seq_along (forecast_dates ),
165
166
labels = as.character(forecast_dates )) +
166
167
theme(axis.text.x = element_text(angle = 90 ),
167
168
panel.grid.major = element_blank(), legend.position = c(.08 , .82 )) +
@@ -183,7 +184,7 @@ forecast_summary_clima <- function(input_dir,
183
184
override.aes = mylist )) +
184
185
scale_y_continuous(sec.axis = sec_axis(~ . ,
185
186
name = myname ,
186
- breaks = 1 : length (labels_obs ),
187
+ breaks = seq_along (labels_obs ),
187
188
labels = labels_obs ))
188
189
}
189
190
0 commit comments