Skip to content

Commit e6f718f

Browse files
committed
initialize predictions with NA in order to fix #96
1 parent 1a1904b commit e6f718f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/helper.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ extract_prediction = function(obj_resampling, learner_class, n_obs,
173173
1:n_iters,
174174
function(x) as.data.table(obj_resampling$predictions("train")[[x]]))
175175
for (i_iter in 1:n_iters) {
176-
preds_vec = vector("numeric", length = n_obs)
176+
preds_vec = as.numeric(rep(NA, n_obs))
177177
f_hat = f_hat_list[[i_iter]]
178178
preds_vec[f_hat[[ind_name]]] = f_hat[[resp_name]]
179179
preds[[i_iter]] = preds_vec
180180
}
181181
} else {
182182
n_obj_rsmp = length(obj_resampling)
183-
preds = vector("list", n_obj_rsmp)
183+
preds = as.numeric(rep(NA, n_obs))
184184
for (i_obj_rsmp in 1:n_obj_rsmp) {
185185
preds_vec = vector("numeric", length = n_obs)
186186
f_hat = as.data.table(obj_resampling[[i_obj_rsmp]]$prediction("train"))
@@ -189,7 +189,7 @@ extract_prediction = function(obj_resampling, learner_class, n_obs,
189189
}
190190
}
191191
} else {
192-
preds = vector("numeric", length = n_obs)
192+
preds = as.numeric(rep(NA, n_obs))
193193
if (testR6(obj_resampling, classes = "ResampleResult")) obj_resampling = list(obj_resampling)
194194
n_obj_rsmp = length(obj_resampling)
195195
for (i_obj_rsmp in 1:n_obj_rsmp) {

0 commit comments

Comments
 (0)