Subtracting a column value which corresponds to a specific value in another column from the every row in that column in R
Advertisements Fish_ID Instance Success First_Success Inst_Diff 1 0 0 0 -2 1 1 0 0 -1 1 2 1 1 0 1 3 0 0 1 1 4 1 0 2 1 5 0 0 3 results %>% group_by(Fish_ID) %>% mutate(Inst_Diff = Instance- Instance[First_Success==1]) I want to create a Inst_Diff column. Using instance number where… Read More Subtracting a column value which corresponds to a specific value in another column from the every row in that column in R