Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 479

Remove the following row if a condition is met

$
0
0

I would like to remove all rows that are followed by the same entry in R. I have the following column in a data frame:

"FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "FAILURE" "HIT"     "FAILURE" "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "FAILURE" "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"    "FAILURE" "HIT"     "FAILURE" "FAILURE" "FAILURE" "HIT" 

I would like to delete all rows in which the "FAILURE" entry is followed by another "FAILURE" entry. So I would like to get the following colomn of the data frame back:

"FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE"  "HIT" "FAILURE" "HIT"     "FAILURE" "HIT" "FAILURE" "HIT"     "FAILURE" "HIT"     "FAILURE" "HIT"    "FAILURE" "HIT" "FAILURE" "HIT" 

How can I check if the next row meets that condition and remove those rows?


Viewing all articles
Browse latest Browse all 479

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>