Made a script using library(getopt) for loading and filtering the data. I think that mem issues were related to using source(). Will find out soon.