determine_winner: Determine if the contestant has won the game or not

Description Usage Arguments Details Value Examples

View source: R/Montyhall.R

Description

determine_winner()is used along with the if()to determine whether the contestant has won the game or not based on his final pick

Usage

1
determine_winner(final.pick, game)

Arguments

The

game[final.pick] is a character vector because it contains character values, as the contestant only has to either choose a "car" door or a "goat" door.

Details

the determine_winner()uses the if() because based on the result we can tell whether the contestant has won or not. It uses the game argument, which is a character vector. It states that if the contestant's final choice was the car door, so the returned result will be "win". If the the contestant's final choice was a a goat door, the returned result will be "lose".

Value

The function returns a length of one character vector indicating whether the contestant has won or not.

Examples

1
2
3
4
        this.game <- c("goat","car","goat")
        determine_winner( final.pick=1, game=this.game )
        determine_winner( final.pick=2, game=this.game )
        determine_winner( final.pick=3, game=this.game )

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