Working with some big data.frames in R, and wanted to know which one of the 2 options is more efficient timewise.
df[which(condition), ] = value
or
df[condition, ] = value
Assuming that most of the data doesn't fulfill the condition, and length(which(condition))
is much much smaller than the boolean vector.
Is it more efficient to ask for specific indices than going through the whole data.frame/vector and for each row/element and choose it if the boolean vector is true at the position.
Or maybe if I call another function, it only delays performance.
I assumed someone else already asked this, but could not find an answer, this seems relevent, but the discussions I saw there are only if you need the boolean vector/indices again.