I have a data frame called (image attached below) where I need to select rows based on conditional values of two columns. Specifically, I need to select those rows where c1Pos and c2Pos have consecutive values (e.g., 4 and 5, 3 and 2, etc.).
I have tried the following, but it doesn't work:
combined_df_locat_short_cues_consec<-subset(combined_df_color_locat_cues, subset=!(c2Pos==c1Pos 1|c1Pos==c1Pos-1))
Any help would be very much appreciated.
Thanks in advance,
Mikel
CodePudding user response:
Please replace
subset=!
withsubset=
c1Pos==c1Pos-1
withc2Pos==c1Pos-1
combined_df_locat_short_cues_consec<-subset(combined_df_color_locat_cues, subset=(c2Pos==c1Pos 1|c2Pos==c1Pos-1))