finished r for data analysis