We need to show the row/column index of the same length. Here, we are trying to get the value of cell at 1, 1,. The row index is correct, but column index is a data.frame with one column (ndx[1] - based on the structure showed in the OP's post). We need to extract the 'V1' column and get the first element as column index
predict_all[1, ndx$V1[1]]
#[1] 0.01
NOTE: We assume predict_all as a data.frame
If it is a data.table, then use with = FALSE
predict_all[1, ndx$V1[1], with = FALSE]
# V1
#1: 0.01
data
ndx <- structure(list(V1 = c(1L, 4L, 5L, 6L)), .Names = "V1",
class = "data.frame", row.names = c(NA, -4L))
predict_all <- structure(list(V1 = c(0.01, 0.2), V2 = c(0, 0.01),
V3 = c(0.2, 0.1), V4 = c(0.4, 0.3), V5 = c(0.1, 0.6),
V6 = c(0, 0.3)), .Names = c("V1",
"V2", "V3", "V4", "V5", "V6"), class = "data.frame",
row.names = c(NA, -2L))