Description Usage Arguments Details Value Examples
The host opens a goat door @description The host has to open a door that is not initially selected by the contestant or a door with a car behind it. In case that the contestant initially selected the Car door, so the host can choose any of the other goat doors.
1 | open_goat_door(game, a.pick)
|
The |
doors object is a numeric vector containing numeric values while the game object includes character vectors. The result returned after running the function is a numeric value between 1 & 3 |
The open_goat_door()was used here for the host to open a goat door. Inside this function, we referred back to two of the previously created objects, game & a.pick. The game object includes character vector "goat, goat, car". The function uses the "if ()". It states that in case the contestant initially selected the car door, so the host will open any of the other 2 doors. The second "if ()" states that if the contestant initially selected one of the two goat doors, so the host will open a door that was not initially selected by the host and that is not a car door.
The function return a length of one numeric vector indicating the goat door opened by the host.
1 2 3 4 5 6 7 | this.game <- c("goat","car","goat")
my.initial.pick <- 1
open_goat_door( this.game, my.initial.pick )
my.initial.pick <- 2
open_goat_door( this.game, my.initial.pick )
my.initial.pick <- 3
open_goat_door( this.game, my.initial.pick )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.