R script for averaging samsung S2 data