change_door: Change the door.

Description Usage Arguments Details Value Examples

View source: R/monty-hall-problem.R

Description

change_door() returns the final contestant's decision on the door position.

Usage

1
change_door(stay = T, opened.door, a.pick)

Arguments

stay

logical vector, default to true.

opened.door

numeric vectors, length 1, between 1 and 3, cannot equal to a.pick.

a.pick

numeric vectors, length 1, between 1 and 3, cannot equal to opened.door.

Details

The contestant is given the option to change from their initial selection to the other door that is still closed. This function first creates a vector of doors numbered 1, 2, 3. Then if the contestant decides to stay, the function will return their final selection of the position on the door to open, which is the same as their initial choice. If the contestant switches, the returned final selection from this function would be the door that has not yet been opened nor has been not selected by the contestant.

Value

The function returns a length 1 numeric vector indicating the contestant's final selection.

Examples

1
2
3
4
  change_door( T, 1, 2 )
  change_door( F, 1, 2 )
  change_door( T, 2, 3 )
  change_door( F, 2, 3 )

lghb2005/montyhall documentation built on Jan. 30, 2021, 12:46 a.m.