code for saving data for use in the R package