Select row prior to first occurrence of an event by group
问题 I have a series of observations that describe if and when an animal is spotted in a specific area. The following sample table identifies when a certain animal is seen ( status == 1 ) or not ( status == 0 ) by day. id date status 1 1 2014-06-20 1 2 1 2014-06-21 1 3 1 2014-06-22 1 4 1 2014-06-23 1 5 1 2014-06-24 0 6 2 2014-06-20 1 7 2 2014-06-21 1 8 2 2014-06-22 0 9 2 2014-06-23 1 10 2 2014-06-24 1 11 3 2014-06-20 1 12 3 2014-06-21 1 13 3 2014-06-22 0 14 3 2014-06-23 1 15 3 2014-06-24 0 16 4