fix R script for small CSV files