New R update stuff

New R code from Eric with the code of processing that we worked on. Note: Eric's working code was not saved because of me, did not do new testing after he rewrote it. So test to see if it works.