open_goat_door: The host opens a goat door.

Description Usage Arguments Details Value Examples

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

Description

open_goat_door() returns the position of a goat door that the host reveals after the contestant's initial random decision. The host will always open a door with a goat behind it. But the door can't be the one the contestant has selected.

Usage

1
open_goat_door(game, a.pick)

Arguments

game

character vector, length 3, any combination of one "car" and two "goat".

a.pick

numeric vectors, length 1, between 1 and 3.

Details

This function first creates a vector of doors numbered 1, 2, 3. Then if the contestant selects a car door, the function will return the position of a goat door selected by the host from any of the two remaining doors that contain the goat. If the contestant selects a non-car door at the first place, the function will return the only goat door position that left for the host.

Value

The function returns a length 1 numeric vector indicating the goat door position that the host reveals.

Examples

1
2
3
  open_goat_door( c("goat","goat","car"), 3 )
  open_goat_door( c("car","goat","goat"), 1 )
  open_goat_door( c("goat","car","goat"), 2 )

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