If I want to list all combinations I can use a nested loop:
for (int i = 1; i <= 5; i++) {
for (int j = i + 1; j <= 5; j++) {
System.out.println("Comparing " + i + " and " + j);
}
}
How would I achieve the same functionality in R? I don't think I correctly understand the syntax for loops in R because this doesn't work (j keeps incrementing above 5).
for (i in 1:5) {
for (j in i+1:5) {
...
}
}