Fixed a few bugs in the R script that were writing data incorrectly.