R code to analyse logs and identify activity