I have a dataframe like this:
     starttime     sx      sy        time
       <chr>      <chr>   <chr>      <chr>
1  1416924247145  667.75  824.25 1416924247145
2  1416924247145 667.875  824.25 1416924247158
3  1416924247145   668.5   824.5 1416924247198
4  1416924257557  231.25  602.25 1416924257557
5  1416924257557 230.625  602.25 1416924257570
6  1416924257557 229.625 601.875 1416924257597
7  1416924257557  228.75  601.25 1416924257610
8  1416924257557   227.5   600.0 1416924257623
9  1416924257557 216.875  587.75 1416924257717
10 1416924257557 207.125 572.625 1416924257797
11 1416924257600 525.425 525.636 1416924259999
I want a subset of this dataframe only containing the rows with the first and last element with equal starttimes. In this example these rows would be 1,3,4,10 and 11. Important is, that the first and last rows also are included. I try to do this with the dplyr package, because it looks suitable for this. I made use of group_by(), filter(), first() and last() functions, but I couldn't get the result I wanted. This is how the result should look like:
 starttime     sx      sy        time
       <chr>      <chr>   <chr>      <chr>
1  1416924247145  667.75  824.25 1416924247145
3  1416924247145   668.5   824.5 1416924247198
4  1416924257557  231.25  602.25 1416924257557
10 1416924257557 207.125 572.625 1416924257797
11 1416924257600 525.425 525.636 1416924259999
 
     
    