0

I am new to R and I am trying to create a third column, of flagged data based on the ID column. Flagging is supposed to be for 0 for Secret identity and 1 for anything else. My table currently looks like this (as an example, not the full table);

    name             ID               
 1. Spider-man       Secret Identity 
 2. Captain America  Public Identity 
 3. Wolverine        Public Identity  
 4. Iron Man         Public Identity  
 5. Thor             No Dual Identity 
 6. Otto Octavius    Secret Identity
 7. Reed Richards    Public Identity

I have had no luck in coding this third column of flagging based on the ID column, listing either '0' or '1' depending on the ID field. Like this;

    name             ID               Flag
 1. Spider-man       Secret Identity  0
 2. Captain America  Public Identity  1 
 3. Wolverine        Public Identity  1
 4. Iron Man         Public Identity  1
 5. Thor             No Dual Identity 1
 6. Otto Octavius    Secret Identity  0
 7. Reed Richards    Public Identity  1

0 Answers0