Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

R: Is there a way to search for a nearly identical row?

$
0
0

This is my original problem: How would I be able to remove opposite values (e.g. refunds) in panel data?

Given the following data:

id|datee      | price | quant | discrete_x
 1 2018-12-19      4    -3000   A
 1 2018-12-04      4     3000   A
 1 2018-12-21      4     3000   B
 1 2018-12-20      3     2000   A
...

this is my desired output:

id|datee      | price | quant | discrete_x
 1 2018-12-21      4     3000   B
 1 2018-12-20      3     2000   A
...

The two removed rows are identical except for date and quant. Is there a way to match two different rows for certain variables?

Another requirement would be to make sure that the negative quant comes after the matching row date-wise.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



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