library(openintro)
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata

#2,21 Drawing box plots. After an introductory statistics course, 80% of students can successfully construct box plots. Of those who can construct box plots, 86% passed, while only 65% of those students who could not construct box plots passed.

#a) Construct a tree diagram of this scenario.

treeDiag(c('',''),c(.8,.2),list(c(.86,.14),c(.65,.35)),c('Could Construct', 'Could Not'),c('Pass','Fail'))

#b) Calculate the probability that a student is able to construct a box plot if it is known that the he passed.

pp <- .688 + .13 #adding total probability to pass
pcnp <- .688
pcgp <- pcnp/pp
pcgp
## [1] 0.8410758