I am working with scraped data on the housing market, and I have a dataset with some duplicates, found conditionally on a set of characteristics. Suppose I have observations A, B, and C with all characteristics being equal except the rent value and the dates (with dateA<dateB<dateC), I consider observations B and C as duplicates, as the ad was just re-posted on the webpage a second and then a third time in order to be re-rented.
I have created a column that tells me if each observation is a duplicate. So I see a column with the standard sequence of "FALSE" "TRUE" "FALSE" "FALSE" "TRUE" values.
I would like to create another column that tells me, in correspondence to the "TRUE", which is its ordinality. For example, in my example, I would like in correspondence to observation B to have the value 2 and in correspondence of the obs C the value 3 and so on.
Is there a way to do so in R?
Thanks.