Modified R script for the factor ingest.