Fix mistakes in R scripts, add R script for generating datasets, and generate answer files for output tests