Generating CSV files for statistics R scripts