Script for R analysis