wrote in solution form my own r file