open_goat_door: The host opens a goat door @description The host has to open...

Description Usage Arguments Details Value Examples

View source: R/Montyhall.R

Description

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.

Usage

1
open_goat_door(game, a.pick)

Arguments

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

Details

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.

Value

The function return a length of one numeric vector indicating the goat door opened by the host.

Examples

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 )

Ma112120/Montyhall documentation built on Dec. 17, 2021, 2:14 a.m.