Utility function first.last(): return first and last element of a vector/list, or first and last row of a dataframe.