Hi, I need help to interpret the following code.

I understand that I'm assigning a sample with binary values with replacement and probability of the value being 0 of 90% and 1 of 10%. What I don't understand is the first part:

# test[disease==0] <- sample(c(0,1)...

Usually square brackets would be to indicate the index e.g., 'test[1]', but in this context, I just don't understand what is happening with a conditional in square brackets. Can anyone assist?

Please, see more of the context in the following code:

```
set.seed(1, sample.kind = "Rounding")
disease <- sample(c(0,1), size=1e6, replace=TRUE, prob=c(0.98,0.02))
test <- rep(NA, 1e6)
test[disease==0] <- sample(c(0,1), size=sum(disease==0), replace=TRUE, prob=c(0.90,0.10))
test[disease==1] <- sample(c(0,1), size=sum(disease==1), replace=TRUE, prob=c(0.15, 0.85))
```