If I were you I will not use a for loop. If you want the index of each item with more than 1 branch, then I think your data set should look something like the following:
branch item
1 1
1 1
2 2
2 1
Now in that case you can use:
# define function for amount of branches
lu <- function(x){
return(length(unique(x)))
}
# aggregate the branches
SUMM <- aggregate(branch ~ item, data = trials, FUN = unique)
# index of those with more than 1 branch
index2 <- which(lapply(SUMM$branch, FUN = lu) > 1)
# if you wanted individual index of the conditions you will be now findished
# if you want the intersection of both conditions you can finish with
allneededindex <- match(index, index2)
To extract all needed rows use:
FINISH <- trials[allneededindex, ]
If you are a beginner and want to know more about R then do check out the following R programming tutorial.