[英]Getting subset of data based on conditional values from two columns
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 (eg, 4 and 5, 3 and 2, etc.).
具体来说,我需要选择 c1Pos 和 c2Pos 具有连续值的那些行(例如,4 和 5、3 和 2 等)。
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米克尔
Please replace请更换
subset=!
with subset=
subset=
c1Pos==c1Pos-1
with c2Pos==c1Pos-1
c1Pos==c1Pos-1
与c2Pos==c1Pos-1
combined_df_locat_short_cues_consec<-subset(combined_df_color_locat_cues, subset=(c2Pos==c1Pos+1|c2Pos==c1Pos-1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.