First of all, I have to say that this is my first post. Despite of having look for the answer using the search toolbox it might be possible that I passed over the right topic without realizing myself, so just in case sorry for that.
Having said that, my problem is the following one:
- I have a data table composed by several columns.
- I have to select the rows that are fullfilling one specific condition ex. which(DT_$var>value, arr.ind = T)) or which(DT_$var>value && DT_$var2>value2, arr.ind = T))
- I have to keep these columns in a new data frame.
My approach was the following one but it is not working, probably because I did not understand the loops correctly:
while (i in nrow(DT)) {
if(DT$var[i]>value){
DT_aux[i]=DT[i]
i<-i+1
}
}
Error in if (DT$value[i] > 45) { : argument is of length zero
I hope that you can help me