I'm a complete R beginner and I've the following question for a project:

Three dice (`D_1`

, `D_2`

, `D_3`

) are rolled and let `S`

be their sum. Use R to:

```
+ Print all the sequences such that `D_1` and `D_2` are both greater than 4 and `S` < 14.
+ Find the conditional probability that `D_1` ana `D_2` are both greater than 3 given that `S` < 15.
+ Find the probability that either the sum of the first two dice is lower than 6 or that `S` < 7.
```

I've managed everything bar the last part and I'm sure I'm just doing something silly but my fried brain can't figure out what!

This is my code:

die <- 1:6

rolls <- expand.grid(die, die, die) # sample space of three dice

R <- data.frame(rolls, rowSums(rolls))

colnames(R) <- c("D_1", "D_2", "D_3", "S")

subset(R,R$D_1 >4 & R$D_2>4 & R$S < 14)

##probability S < 15

B<-sum(R$S <15)/(dim(R)[1])

##probability D_1 and D_2 >3 and S<15

A<-sum(R$D_1>3 &R$D_2>3 & R$S <15)/dim(R)[1]

##probability that D_1 and D_2 >3 given S<15

condprob<-A/B

condprob

##probability that D_1+D_2<6 OR S<7

sum(R$D_1+D_2<6|R$S<7)/dim(R)[1]

why wont it recognise D_2 in final line of code?

Any help much appreciated.