Implementation of some data analysis in R