I am trying to add a column of flagged data, where "Secret Identity is 0, and everything else is 1. My table currently looks like this;
name ID
Spider-Man Secret Identity
Captain America Public Identity
Wolverine Public Identity
Iron Man Public Identity
Thor No Dual Identity
Benjamin Grimm Public Identity
Reed Richards Public Identity
Otto Octavius Secret Identity
Hulk Public Identity
Scott Summers Public Identity
Johnathan Storm Public Identity
Katherine Pryde Secret Identity
As for coding it;
characters %>% mutate(FLAG = case_when(ID == "Secret Identity" ~ 0, TRUE ~ 1))
This seems to work, however I also needed a new field or column listing either '0' or '1' depending on the ID field. Like this;
name ID Flag
Spider-Man Secret Identity 1
Captain America Public Identity 0
Wolverine Public Identity 0
Iron Man Public Identity 0
Thor No Dual Identity 0
Benjamin Grimm Public Identity 0
Reed Richards Public Identity 0
Otto Octavius Secret Identity 1
Hulk Public Identity 0
Scott Summers Public Identity 0
Johnathan Storm Public Identity 0
Katherine Pryde Secret Identity 1