Learn R Programming

survivoR (version 2.3.5)

add_alive: Adds alive flag

Description

Adds a logical flag if the castaway is alive at the start or end of an episode

Usage

add_alive(df, .ep, .at = "end")

Value

A data frame with a new column alive.

Arguments

df

Data frame. Must contain version_season and castaway.

.ep

Episode to evaluate the flag.

.at

Either 'start' or 'end'. If 'start' the flag will indicate who is alive at the start of the episode. If 'end' it will indicate who is alive at the end of the episode i.e. after tribal council.

Examples

Run this code

library(survivoR)
library(dplyr)

df <- confessionals |>
  filter_us(47) |>
  add_alive(12)

df |>
  filter(alive) |>
  group_by(castaway) |>
  summarise(n = sum(confessional_count))

Run the code above in your browser using DataLab