change_door: Contestant chooses to stay or change doors.

Description Usage Arguments Details Value Examples

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

Description

‘change_door()' generates the contestant’s final pick. They can iether stay with their first pick, or change with the last unopened door.

Usage

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

Arguments

'stay'

- This tells the function if the contestant stayed with their initial pick or not. 'opened.door' - This tells the function which door was opened. ‘a.pick' - This tells the function what the contestant’s inital door pick was.

Details

This function uses if statements that determine if the contestant stayed or changed doors. If the contested stayed, then it turns the contestants inital door pick into a final pick that is returned. If the contestant did not stay, then it passes the final unopened door into the final pick and returns that door instead.

Value

The functions returns a number between 1 and 3 that represents the contestants final door pick.

Examples

1
2
  change_door( stay=T, opened.door, first.pick )
  change_door( stay=F, 3, 1)

Vodkard/montyhall documentation built on Feb. 27, 2020, 12:42 a.m.