finding start and end time of each session id in r
Assuming you have access to dplyr package, you can do the following. 


data %&gt;% group_by(session_id) %&gt;% summarise(start_time = min(timestamp), end_time = max(timestamp), unique_items=length(unique(item_id)))