put code for df_to_dat file in it's own r file, and replaced this code with line that sources code ( source() )